Question

How to find all available interfaces defined in the class using Apache BeanUtils, MethodUtils etc. ?

public class MyClass() {
   .....
   public interface Interface1{};
   public interface Interface2{};
}
Was it helpful?

Solution

I suspect you just want Class.getClasses():

Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this Class object has no public member classes or interfaces. This method also returns an array of length 0 if this Class object represents a primitive type, an array class, or void.

So call MyClass.class.getClasses(), and then filter out non-interfaces using Class.isInterface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top