Class PioneerAnnotationUtils
java.lang.Object
org.junitpioneer.internal.PioneerAnnotationUtils
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static List<Annotation> collectArgumentSources(Parameter parameter) 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 specifiedcontext.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 specifiedcontext.static <A extends Annotation>
List<Annotation> findAnnotatedAnnotations(AnnotatedElement element, Class<A> annotation) Returns the annotations present on theAnnotatedElementthat are themselves annotated with the specified annotation.(package private) static <A extends Annotation>
Stream<A> findAnnotations(org.junit.jupiter.api.extension.ExtensionContext context, Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing) 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 specifiedcontext.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 specifiedcontext.static List<Annotation> findMethodArgumentsSources(Method testMethod) private static <A extends Annotation>
List<A> findOnMethod(Method element, Class<A> annotationType, boolean findRepeated) private static <A extends Annotation>
Stream<A> findOnOuterClasses(Optional<Class<?>> type, Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing) private static <A extends Annotation>
List<A> findOnType(Class<?> element, Class<A> annotationType, boolean findRepeated, boolean findAllEnclosing) static List<Annotation> findParameterArgumentsSources(Method testMethod) private static Stream<Annotation> flatten(Annotation annotation) static booleanisAnnotationPresent(org.junit.jupiter.api.extension.ExtensionContext context, Class<? extends 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, Class<? extends 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(Annotation annotation) private static booleanisContainerAnnotationOf(Annotation potentialContainer, Class<?> potentialRepeatable)
-
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 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, Class<? extends 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 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 specifiedcontext. 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 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 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 specifiedcontext. 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 specifiedcontext. 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 theAnnotatedElementthat are themselves annotated with the specified annotation. The meta-annotation can be present, indirectly present, or meta-present. -
flatten
-
isContainerAnnotation
-
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
-
collectArgumentSources
-
findMethodArgumentsSources
-