Determine if a Type implements an interface

Unlike Java, where the “Class“ can be constructed and checked for inheritance, the Type in Apex is fairly limited. One of the few operations it permits is instantiation as an Object of the Type.

The instanceof operator applies only to Object Instances, which would imply that the Type will have to be instantiated to check for inheritance.

(An alternative to instanceof might be attempting to cast it to the interface and handling the 'CastException')

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_type.htm

Whilst I understand your intention to avoid loading any expensive construction logic, I'm guessing you will have to construct the classes for purposes of the actual callback.


The Winter '20 release will include the new System.Type.isAssignableFrom(sourceType) method.

This avoids the need to create an actual instance of a class type to determine if it is assignable to another type.

E.g.

string className = 'someCustomClientClass';
Type t = Type.forName(className);

System.assert(SomeClass.SomeInterface.class.isAssignableFrom(t);