Class AnnotationUtils

java.lang.Object
io.micronaut.test.annotation.AnnotationUtils

public final class AnnotationUtils extends Object
Common annotation utilities.
Since:
1.0.1
  • Method Details

    • findRepeatableAnnotations

      public static <A extends Annotation> List<A> findRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)
      Find all repeatable annotations of annotationType that are either present, indirectly present, or meta-present on the supplied AnnotatedElement.

      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 is null, this method simply returns an empty list.

      Type Parameters:
      A - the annotation instance
      Parameters:
      element - the element to search on, potentially null
      annotationType - the repeatable annotation type to search for; never null
      Returns:
      the list of all such annotations found; neither null nor mutable
      See Also: