I\'m exploring annotations and came to a point where some annotations seems to have a hierarchy among them.
I\'m using annotations to generate code in the backgroun
In addition to Grygoriys answer of annotating annotations.
You can check e.g. methods for containing a @Qualifier annotation (or an annotation annotated with @Qualifier
) by this loop:
for (Annotation a : method.getAnnotations()) {
if (a.annotationType().isAnnotationPresent(Qualifier.class)) {
System.out.println("found @Qualifier annotation");//found annotation having Qualifier annotation itself
}
}
What you're basically doing, is to get all annotations present on the method and of those annotations you get their types and check those types if they're annotated with @Qualifier. Your annotation needs to be Target.Annotation_type enabled as well to get this working.