lundi 14 août 2017

Java reflections: all classes which have a certain annotation and implement a certain interface

I am using org.reflections to find certain classes in a multi module application.

I am able to find all classes which are implementing a certain interface:

Reflections reflections = new Reflections("my.package");    
Set<Class<? extends MyInterface>> ddd = reflections.getSubTypesOf(MyInterface.class);

I am able to find all classes which are having a certain annotation.

Reflections reflections = new Reflections("my.package");
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(MyAnnotation.class);

However, i can't find a way to find all classes that are implementing that interface AND have the wanted annotation.

How can I combine these two approaches? Is it even possible?

Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire