- java.lang.Object
-
- org.junitpioneer.internal.PioneerAnnotationUtils
-
public class PioneerAnnotationUtils extends java.lang.ObjectPioneer-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 Summary
Constructors Modifier Constructor Description privatePioneerAnnotationUtils()
-
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 specifiedcontext.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 specifiedcontext.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 theAnnotatedElementthat 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 specifiedcontext.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 specifiedcontext.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 booleanisAnnotationPresent(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Determines whether an annotation of the specifiedannotationTypeis either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specifiedcontext.static booleanisAnyRepeatableAnnotationPresent(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Determines whether an annotation of the specified repeatableannotationTypeis either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specifiedcontext.static booleanisContainerAnnotation(java.lang.annotation.Annotation annotation)private static booleanisContainerAnnotationOf(java.lang.annotation.Annotation potentialContainer, java.lang.Class<?> potentialRepeatable)
-
-
-
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 specifiedannotationTypeis either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specifiedcontext.
-
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 repeatableannotationTypeis either present, indirectly present, meta-present, or enclosing-present on the test element (method or class) belonging to the specifiedcontext.
-
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 specifiedcontext. 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 specifiedcontext. 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 specifiedcontext. 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 specifiedcontext. 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 theAnnotatedElementthat 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)
-
-