jeudi 28 juillet 2016

Find class marked with annotation of a specific value

I'm using this Java Reflections API that I'm finding quite convenient so far:

http://ift.tt/Ofz26b

Find all classes marked with a specific annotation is dead easy, however, I can't figure out how to add a filter in the scanner to retrieve classes that have that annotation configured in a certain way.

For example, if I have three classes:

@Important(level="high")
public class HighlyImportant { }

@Important(level="medium")
public class ModeratelyImportant { }

@Important(level="low")
public class NotSoImportant { }

I can get all three classes by scanning for the @Important annotation, but how do I restrict that to only @Important(level=high) ?

Thanks





Aucun commentaire:

Enregistrer un commentaire