@API(status=INTERNAL,
since="1.0")
public final class AnnotationUtils
extends Object
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 AnnotationSupport
class.
Annotation,
AnnotatedElement,
AnnotationSupport| Modifier and Type | Method and 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 specified
annotationType and match the specified predicate, 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 specified
annotationType and match the specified predicate. |
static List<Method> |
findAnnotatedMethods(Class<?> clazz,
Class<? extends Annotation> annotationType,
ReflectionUtils.HierarchyTraversalMode traversalMode) |
static <A extends Annotation> |
findAnnotation(AnnotatedElement element,
Class<A> annotationType) |
static <A extends Annotation> |
findAnnotation(Optional<? extends AnnotatedElement> element,
Class<A> annotationType) |
static List<Field> |
findPublicAnnotatedFields(Class<?> clazz,
Class<?> fieldType,
Class<? extends Annotation> annotationType) |
static <A extends Annotation> |
findRepeatableAnnotations(AnnotatedElement element,
Class<A> annotationType) |
static boolean |
isAnnotated(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Determine if an annotation of
annotationType is either
present or meta-present on the supplied
element. |
static boolean |
isAnnotated(Optional<? extends AnnotatedElement> element,
Class<? extends Annotation> annotationType)
Determine if an annotation of
annotationType is either
present or meta-present on the supplied optional
element. |
public static boolean isAnnotated(Optional<? extends AnnotatedElement> element, Class<? extends Annotation> annotationType)
annotationType is either
present or meta-present on the supplied optional
element.public static boolean isAnnotated(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType is either
present or meta-present on the supplied
element.element - the element on which to search for the annotation; may be
nullannotationType - the annotation type to search for; never nulltrue if the annotation is present or meta-presentfindAnnotation(AnnotatedElement, Class),
AnnotationSupport.isAnnotated(AnnotatedElement, Class)public static <A extends Annotation> Optional<A> findAnnotation(Optional<? extends AnnotatedElement> element, Class<A> annotationType)
public static <A extends Annotation> Optional<A> findAnnotation(AnnotatedElement element, Class<A> annotationType)
public static <A extends Annotation> List<A> findRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)
public static List<Field> findPublicAnnotatedFields(Class<?> clazz, Class<?> fieldType, Class<? extends Annotation> annotationType)
public static List<Field> findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate)
annotationType and match the specified predicate, using
top-down search semantics within the type hierarchy.#findAnnotatedFields(Class, Class, Predicate, HierarchyTraversalMode)public static List<Field> findAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType, Predicate<Field> predicate, ReflectionUtils.HierarchyTraversalMode traversalMode)
annotationType and match the specified predicate.clazz - the class or interface in which to find the fields; never nullannotationType - the annotation type to search for; never nullpredicate - the field filter; never nulltraversalMode - the hierarchy traversal mode; never nullnull nor mutablepublic static List<Method> findAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType, ReflectionUtils.HierarchyTraversalMode traversalMode)
Copyright © 2024. All rights reserved.