I need to determine if a Class object representing an interface extends another interface, ie:
package a.b.c.d; public Interface IMyInterface extends a.b.d.c.ISomeOtherInterface{ }
according to the spec Class.getSuperClass() will return null for an Interface.
If this Class represents either the Object class, an interface, a primitive type, or void, then null is returned.
Therefore the following won’t work.
Class interface = Class.ForName('a.b.c.d.IMyInterface') Class extendedInterface = interface.getSuperClass(); if(extendedInterface.getName().equals('a.b.d.c.ISomeOtherInterface')){ //do whatever here }
any ideas?
Use Class.getInterfaces such as:
Also the following code might be of help, it will give you a set with all super-classes and interfaces of a certain class:
Edit: Added some code to get all super-classes and interfaces of a certain class.