mariusz12 mariusz12 - 4 months ago 8
Java Question

Finding class extended Class and implement Interface

I try to use google reflections to finding class which extended abstract class like A and implement interface I. I looked in API but with no result.
My code so far:

Reflections reflections = new Reflections("");
Set<Class<? extends A>> subTypes = reflections.getSubTypesOf(A.class);

Can any one suggest how I can add next conditions?


I suppose (did not test), this will filter out the right interfaces in the forEach loop:

for(Class face : clazz.getInterfaces())  {
    if( face.isAssignableFrom(I))  ... do sth ...;

I is the I.class of the interface you are looking for.