A safe method of determining whether a class implements a particular interface