Class PioneerAnnotationUtils

java.lang.Object
org.junitpioneer.internal.PioneerAnnotationUtils

public class PioneerAnnotationUtils extends 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.

  • Constructor Details

    • PioneerAnnotationUtils

      private PioneerAnnotationUtils()
  • Method Details

    • isAnnotationPresent

      public static boolean isAnnotationPresent(org.junit.jupiter.api.extension.ExtensionContext context, Class<? extends 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, Class<? extends 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 Annotation> Optional<A> findClosestEnclosingAnnotation(org.junit.jupiter.api.extension.ExtensionContext context, 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 Annotation> Stream<A> findClosestEnclosingRepeatableAnnotations(org.junit.jupiter.api.extension.ExtensionContext context, 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 Annotation> Stream<A> findAllEnclosingAnnotations(org.junit.jupiter.api.extension.ExtensionContext context, 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 Annotation> Stream<A> findAllEnclosingRepeatableAnnotations(org.junit.jupiter.api.extension.ExtensionContext context, 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 Annotation> List<Annotation> findAnnotatedAnnotations(AnnotatedElement element, 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 Stream<Annotation> flatten(Annotation annotation)
    • isContainerAnnotation

      public static boolean isContainerAnnotation(Annotation annotation)
    • isContainerAnnotationOf

      private static boolean isContainerAnnotationOf(Annotation potentialContainer, Class<?> potentialRepeatable)
    • findAnnotations

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

      private static <A extends Annotation> List<A> findOnMethod(Method element, Class<A> annotationType, boolean findRepeated)
    • findOnOuterClasses

      private static <A extends Annotation> Stream<A> findOnOuterClasses(Optional<Class<?>> type, Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing)
    • findOnType

      private static <A extends Annotation> List<A> findOnType(Class<?> element, Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing)
    • findParameterArgumentsSources

      public static List<Annotation> findParameterArgumentsSources(Method testMethod)
    • collectArgumentSources

      private static List<Annotation> collectArgumentSources(Parameter parameter)
    • findMethodArgumentsSources

      public static List<Annotation> findMethodArgumentsSources(Method testMethod)