Class PioneerAnnotationUtils


  • public class PioneerAnnotationUtils
    extends java.lang.Object
    Pioneer-internal utility class to handle annotations. DO NOT USE THIS CLASS - IT MAY CHANGE SIGNIFICANTLY IN ANY MINOR UPDATE.

    It uses the following terminology to describe annotations that are not immediately present on an element:

    • indirectly present if a supertype of the element is annotated
    • meta-present if an annotation that is present on the element is itself annotated
    • enclosing-present if an enclosing type (think opposite of @Nested) is annotated

    All of the above mechanisms apply recursively, meaning that, e.g., for an annotation to be meta-present it can present on an annotation that is present on another annotation that is present on the element.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.List<java.lang.annotation.Annotation> collectArgumentSources​(java.lang.reflect.Parameter parameter)  
      static <A extends java.lang.annotation.Annotation>
      java.util.stream.Stream<A>
      findAllEnclosingAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<A> annotationType)
      Returns the specified annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      static <A extends java.lang.annotation.Annotation>
      java.util.stream.Stream<A>
      findAllEnclosingRepeatableAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<A> annotationType)
      Returns the specified repeatable annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      static <A extends java.lang.annotation.Annotation>
      java.util.List<java.lang.annotation.Annotation>
      findAnnotatedAnnotations​(java.lang.reflect.AnnotatedElement element, java.lang.Class<A> annotation)
      Returns the annotations present on the AnnotatedElement that are themselves annotated with the specified annotation.
      (package private) static <A extends java.lang.annotation.Annotation>
      java.util.stream.Stream<A>
      findAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing)  
      static <A extends java.lang.annotation.Annotation>
      java.util.Optional<A>
      findClosestEnclosingAnnotation​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<A> annotationType)
      Returns the specified annotation if it is either present, meta-present, enclosing-present, or indirectly present on the test element (method or class) belonging to the specified context.
      static <A extends java.lang.annotation.Annotation>
      java.util.stream.Stream<A>
      findClosestEnclosingRepeatableAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<A> annotationType)
      Returns the specified repeatable annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      static java.util.List<java.lang.annotation.Annotation> findMethodArgumentsSources​(java.lang.reflect.Method testMethod)  
      private static <A extends java.lang.annotation.Annotation>
      java.util.List<A>
      findOnMethod​(java.lang.reflect.Method element, java.lang.Class<A> annotationType, boolean findRepeated)  
      private static <A extends java.lang.annotation.Annotation>
      java.util.stream.Stream<A>
      findOnOuterClasses​(java.util.Optional<java.lang.Class<?>> type, java.lang.Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing)  
      private static <A extends java.lang.annotation.Annotation>
      java.util.List<A>
      findOnType​(java.lang.Class<?> element, java.lang.Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing)  
      static java.util.List<java.lang.annotation.Annotation> findParameterArgumentsSources​(java.lang.reflect.Method testMethod)  
      private static java.util.stream.Stream<java.lang.annotation.Annotation> flatten​(java.lang.annotation.Annotation annotation)  
      static boolean isAnnotationPresent​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Determines whether an annotation of the specified annotationType is either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      static boolean isAnyRepeatableAnnotationPresent​(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Determines whether an annotation of the specified repeatable annotationType is either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      static boolean isContainerAnnotation​(java.lang.annotation.Annotation annotation)  
      private static boolean isContainerAnnotationOf​(java.lang.annotation.Annotation potentialContainer, java.lang.Class<?> potentialRepeatable)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PioneerAnnotationUtils

        private PioneerAnnotationUtils()
    • Method Detail

      • isAnnotationPresent

        public static boolean isAnnotationPresent​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                  java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Determines whether an annotation of the specified annotationType is either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      • isAnyRepeatableAnnotationPresent

        public static boolean isAnyRepeatableAnnotationPresent​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                               java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Determines whether an annotation of the specified repeatable annotationType is either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context.
      • findClosestEnclosingAnnotation

        public static <A extends java.lang.annotation.Annotation> java.util.Optional<A> findClosestEnclosingAnnotation​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                                                                                       java.lang.Class<A> annotationType)
        Returns the specified annotation if it is either present, meta-present, enclosing-present, or indirectly present on the test element (method or class) belonging to the specified context. If the annotations are present on more than one enclosing type, the closest ones are returned.
      • findClosestEnclosingRepeatableAnnotations

        public static <A extends java.lang.annotation.Annotation> java.util.stream.Stream<A> findClosestEnclosingRepeatableAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                                                                                                       java.lang.Class<A> annotationType)
        Returns the specified repeatable annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context. If the annotations are present on more than one enclosing type, the instances on the closest one are returned.
      • findAllEnclosingAnnotations

        public static <A extends java.lang.annotation.Annotation> java.util.stream.Stream<A> findAllEnclosingAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                                                                                         java.lang.Class<A> annotationType)
        Returns the specified annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context. If the annotations are present on more than one enclosing type, all instances are returned.
      • findAllEnclosingRepeatableAnnotations

        public static <A extends java.lang.annotation.Annotation> java.util.stream.Stream<A> findAllEnclosingRepeatableAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                                                                                                   java.lang.Class<A> annotationType)
        Returns the specified repeatable annotations if they are either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specified context. If the annotation is present on more than one enclosing type, all instances are returned.
      • findAnnotatedAnnotations

        public static <A extends java.lang.annotation.Annotation> java.util.List<java.lang.annotation.Annotation> findAnnotatedAnnotations​(java.lang.reflect.AnnotatedElement element,
                                                                                                                                           java.lang.Class<A> annotation)
        Returns the annotations present on the AnnotatedElement that are themselves annotated with the specified annotation. The meta-annotation can be present, indirectly present, or meta-present.
      • flatten

        private static java.util.stream.Stream<java.lang.annotation.Annotation> flatten​(java.lang.annotation.Annotation annotation)
      • isContainerAnnotation

        public static boolean isContainerAnnotation​(java.lang.annotation.Annotation annotation)
      • isContainerAnnotationOf

        private static boolean isContainerAnnotationOf​(java.lang.annotation.Annotation potentialContainer,
                                                       java.lang.Class<?> potentialRepeatable)
      • findAnnotations

        static <A extends java.lang.annotation.Annotation> java.util.stream.Stream<A> findAnnotations​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                                                                      java.lang.Class<A> annotationType,
                                                                                                      boolean findRepeated,
                                                                                                      boolean findAllEnclosing)
      • findOnMethod

        private static <A extends java.lang.annotation.Annotation> java.util.List<A> findOnMethod​(java.lang.reflect.Method element,
                                                                                                  java.lang.Class<A> annotationType,
                                                                                                  boolean findRepeated)
      • findOnOuterClasses

        private static <A extends java.lang.annotation.Annotation> java.util.stream.Stream<A> findOnOuterClasses​(java.util.Optional<java.lang.Class<?>> type,
                                                                                                                 java.lang.Class<A> annotationType,
                                                                                                                 boolean findRepeated,
                                                                                                                 boolean findAllEnclosing)
      • findOnType

        private static <A extends java.lang.annotation.Annotation> java.util.List<A> findOnType​(java.lang.Class<?> element,
                                                                                                java.lang.Class<A> annotationType,
                                                                                                boolean findRepeated,
                                                                                                boolean findAllEnclosing)
      • findParameterArgumentsSources

        public static java.util.List<java.lang.annotation.Annotation> findParameterArgumentsSources​(java.lang.reflect.Method testMethod)
      • collectArgumentSources

        private static java.util.List<java.lang.annotation.Annotation> collectArgumentSources​(java.lang.reflect.Parameter parameter)
      • findMethodArgumentsSources

        public static java.util.List<java.lang.annotation.Annotation> findMethodArgumentsSources​(java.lang.reflect.Method testMethod)