Class AnnotationUtils
- Since:
- 1.0.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends Annotation>
List<A>findRepeatableAnnotations
(AnnotatedElement element, Class<A> annotationType) Find all repeatable annotations ofannotationType
that are either present, indirectly present, or meta-present on the suppliedAnnotatedElement
.
-
Method Details
-
findRepeatableAnnotations
public static <A extends Annotation> List<A> findRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType) Find all repeatable annotations ofannotationType
that are either present, indirectly present, or meta-present on the suppliedAnnotatedElement
.This method extends the functionality of
AnnotatedElement.getAnnotationsByType(Class)
with additional support for meta-annotations.In addition, if the element is a class and the repeatable annotation is
@Inherited
, this method will search on superclasses first in order to support top-down semantics. The result is that this algorithm finds repeatable annotations that would be shadowed and therefore not visible according to Java's standard semantics for inherited, repeatable annotations.If the element is a class and the repeatable annotation is not discovered within the class hierarchy, this method will additionally search on interfaces implemented by each class in the hierarchy.
If the supplied
element
isnull
, this method simply returns an empty list.- Type Parameters:
A
- the annotation instance- Parameters:
element
- the element to search on, potentiallynull
annotationType
- the repeatable annotation type to search for; nevernull
- Returns:
- the list of all such annotations found; neither
null
nor mutable - See Also:
-