findAnnotation
Find a single Annotation of annotationType on the supplied Class, traversing its interfaces, annotations, and superclasses if the annotation is not directly present on the given class itself.
This method explicitly handles class-level annotations which are not declared as inheritedas well as meta-annotations and annotations on interfaces.
The algorithm operates as follows:
- Search for the annotation on the given class and return it if found.
- Recursively search through all interfaces that the given class declares.
- Recursively search through the superclass hierarchy of the given class.
Note: in this context, the term recursively means that the search process continues by returning to step #1 with the current interface, annotation, or superclass as the class to look for annotations on.
Return
the first matching annotation, or null if not found
Parameters
the class to look for annotations on
the type of annotation to look for
Find a single Annotation of annotationType on the supplied Method, traversing its super methods if the annotation is not directly present on the given method itself.
Annotations on methods are not inherited by default, so we need to handle this explicitly.
Return
the first matching annotation, or null if not found
Parameters
the method to look for annotations on
the type of annotation to look for