Package org.junit.platform.commons.util
Class AnnotationUtils
- java.lang.Object
-
- org.junit.platform.commons.util.AnnotationUtils
-
@API(status=INTERNAL, since="1.0") public final class AnnotationUtils extends Object
Collection of utilities for working with annotations.DISCLAIMER
These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!
Some utilities are published via the maintained
AnnotationSupportclass.- Since:
- 1.0
- See Also:
Annotation,AnnotatedElement,AnnotationSupport
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Field>findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate)Find all fields of the supplied class or interface that are annotated or meta-annotated with the specifiedannotationTypeand match the specifiedpredicate, using top-down search semantics within the type hierarchy.static List<Field>findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate, ReflectionUtils.HierarchyTraversalMode traversalMode)Find all fields of the supplied class or interface that are annotated or meta-annotated with the specifiedannotationTypeand match the specifiedpredicate.static List<Method>findAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType, ReflectionUtils.HierarchyTraversalMode traversalMode)static <A extends Annotation>
Optional<A>findAnnotation(AnnotatedElement element, Class<A> annotationType)static <A extends Annotation>
Optional<A>findAnnotation(Optional<? extends AnnotatedElement> element, Class<A> annotationType)static List<Field>findPublicAnnotatedFields(Class<?> clazz, Class<?> fieldType, Class<? extends Annotation> annotationType)static <A extends Annotation>
List<A>findRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)static booleanisAnnotated(AnnotatedElement element, Class<? extends Annotation> annotationType)Determine if an annotation ofannotationTypeis either present or meta-present on the suppliedelement.static booleanisAnnotated(Optional<? extends AnnotatedElement> element, Class<? extends Annotation> annotationType)Determine if an annotation ofannotationTypeis either present or meta-present on the supplied optionalelement.
-
-
-
Method Detail
-
isAnnotated
public static boolean isAnnotated(Optional<? extends AnnotatedElement> element, Class<? extends Annotation> annotationType)
Determine if an annotation ofannotationTypeis either present or meta-present on the supplied optionalelement.
-
isAnnotated
public static boolean isAnnotated(AnnotatedElement element, Class<? extends Annotation> annotationType)
Determine if an annotation ofannotationTypeis either present or meta-present on the suppliedelement.
-
findAnnotation
public static <A extends Annotation> Optional<A> findAnnotation(Optional<? extends AnnotatedElement> element, Class<A> annotationType)
-
findAnnotation
public static <A extends Annotation> Optional<A> findAnnotation(AnnotatedElement element, Class<A> annotationType)
-
findRepeatableAnnotations
public static <A extends Annotation> List<A> findRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)
-
findPublicAnnotatedFields
public static List<Field> findPublicAnnotatedFields(Class<?> clazz, Class<?> fieldType, Class<? extends Annotation> annotationType)
-
findAnnotatedFields
public static List<Field> findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate)
Find all fields of the supplied class or interface that are annotated or meta-annotated with the specifiedannotationTypeand match the specifiedpredicate, using top-down search semantics within the type hierarchy.
-
findAnnotatedFields
public static List<Field> findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate, ReflectionUtils.HierarchyTraversalMode traversalMode)
Find all fields of the supplied class or interface that are annotated or meta-annotated with the specifiedannotationTypeand match the specifiedpredicate.- Parameters:
clazz- the class or interface in which to find the fields; nevernullannotationType- the annotation type to search for; nevernullpredicate- the field filter; nevernulltraversalMode- the hierarchy traversal mode; nevernull- Returns:
- the list of all such fields found; neither
nullnor mutable
-
findAnnotatedMethods
public static List<Method> findAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType, ReflectionUtils.HierarchyTraversalMode traversalMode)
-
-