public interface AnnotationUtils
| Modifier and Type | Method and Description |
|---|---|
static Predicate<Annotation> |
excludedType(Class<? extends Annotation> excludedAnnotationType)
Build an instance of
Predicate to excluded annotation type |
static <A extends Annotation> |
findAnnotation(AnnotatedElement annotatedElement,
Class<A> annotationType)
Find the annotation that is annotated on the specified element may be a meta-annotation
|
static <A extends Annotation> |
findAnnotation(AnnotatedElement annotatedElement,
String annotationClassName)
Find the annotation that is annotated on the specified element may be a meta-annotation
|
static <A extends Annotation> |
findMetaAnnotation(AnnotatedElement annotatedElement,
Class<A> metaAnnotationType)
Find the meta annotation from the annotated element by meta annotation type
|
static <A extends Annotation> |
findMetaAnnotation(AnnotatedElement annotatedElement,
String metaAnnotationClassName)
Find the meta annotation from the annotated element by meta annotation type
|
static <A extends Annotation> |
findMetaAnnotation(Class<? extends Annotation> annotationType,
Class<A> metaAnnotationType)
Find the meta annotation from the annotation type by meta annotation type
|
static <A extends Annotation> |
findMetaAnnotations(AnnotatedElement annotatedElement,
Class<A> metaAnnotationType)
Find the meta annotations from the the the annotated element by meta annotation type
|
static <A extends Annotation> |
findMetaAnnotations(Class<? extends Annotation> annotationType,
Class<A> metaAnnotationType)
Find the meta annotations from the the
annotation type by meta annotation type |
static List<Annotation> |
getAllDeclaredAnnotations(AnnotatedElement annotatedElement,
Predicate<Annotation>... annotationsToFilter)
Get all directly declared annotations of the the annotated element, not including
meta annotations.
|
static List<Annotation> |
getAllDeclaredAnnotations(Class<?> type,
Predicate<Annotation>... annotationsToFilter)
Get all directly declared annotations of the specified type and its' all hierarchical types, not including
meta annotations.
|
static List<Annotation> |
getAllMetaAnnotations(Class<? extends Annotation> annotationType,
Predicate<Annotation>... annotationsToFilter)
Get all meta annotations from the specified
annotation type |
static <A extends Annotation> |
getAnnotation(AnnotatedElement annotatedElement,
String annotationClassName)
|
static <T> T |
getAttribute(Annotation annotation,
String attributeName)
Get the attribute from the specified
annotation |
static List<Annotation> |
getDeclaredAnnotations(AnnotatedElement annotatedElement,
Predicate<Annotation>... annotationsToFilter)
Get annotations that are directly present on this element.
|
static List<Annotation> |
getMetaAnnotations(Class<? extends Annotation> annotationType,
Predicate<Annotation>... metaAnnotationsToFilter)
|
static <T> T |
getValue(Annotation annotation)
Get the "value" attribute from the specified
annotation |
static boolean |
isAllAnnotationPresent(Class<?> type,
Class<? extends Annotation>... annotationTypes)
Tests the annotated element is annotated all specified annotations or not
|
static boolean |
isAnnotationPresent(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType)
Tests the annotated element is present any specified annotation types
|
static boolean |
isAnnotationPresent(AnnotatedElement annotatedElement,
String annotationClassName)
Tests the annotated element is present any specified annotation types
|
static boolean |
isAnnotationPresent(Class<?> type,
boolean matchAll,
Class<? extends Annotation>... annotationTypes)
Tests the annotated element is annotated the specified annotations or not
|
static boolean |
isAnnotationPresent(Class<?> type,
Class<? extends Annotation> annotationType)
Tests the annotated element is annotated the specified annotation or not
|
static boolean |
isAnyAnnotationPresent(Class<?> type,
Class<? extends Annotation>... annotationTypes)
Tests the annotated element is present any specified annotation types
|
static boolean |
isSameType(Annotation annotation,
Class<? extends Annotation> annotationType)
Is the type of specified annotation same to the expected type?
|
static boolean |
isType(AnnotatedElement annotatedElement)
Is the specified type a generic
type |
static <A extends Annotation> |
resolveAnnotationType(AnnotatedElement annotatedElement,
String annotationClassName)
Resolve the annotation type by the annotated element and resolved class name
|
static <A extends Annotation> Class<A> resolveAnnotationType(AnnotatedElement annotatedElement, String annotationClassName)
A - the type of annotationannotatedElement - the annotated elementannotationClassName - the class name of annotationnullstatic boolean isType(AnnotatedElement annotatedElement)
typeannotatedElement - the annotated elementannotatedElement is the Class, return true, or falseElementType.TYPEstatic boolean isSameType(Annotation annotation, Class<? extends Annotation> annotationType)
annotation - the specified AnnotationannotationType - the expected annotation typetrue, or falsestatic Predicate<Annotation> excludedType(Class<? extends Annotation> excludedAnnotationType)
Predicate to excluded annotation typeexcludedAnnotationType - excluded annotation typestatic <T> T getAttribute(Annotation annotation, String attributeName) throws IllegalArgumentException
annotationT - the type of attributeannotation - the specified annotationattributeName - the attribute nameIllegalArgumentException - If the attribute name can't be foundstatic <T> T getValue(Annotation annotation) throws IllegalArgumentException
annotationT - the type of attributeannotation - the specified annotationIllegalArgumentException - If the attribute name can't be foundstatic <A extends Annotation> A getAnnotation(AnnotatedElement annotatedElement, String annotationClassName) throws ClassCastException
A - The type of AnnotationannotatedElement - AnnotatedElementannotationClassName - the class name of annotationAnnotation if foundClassCastException - If the annotation type that client requires can't match actual typestatic List<Annotation> getDeclaredAnnotations(AnnotatedElement annotatedElement, Predicate<Annotation>... annotationsToFilter)
annotatedElement - the annotated elementannotationsToFilter - the annotations to filterListstatic List<Annotation> getAllDeclaredAnnotations(AnnotatedElement annotatedElement, Predicate<Annotation>... annotationsToFilter)
annotatedElement - the annotated elementannotationsToFilter - the annotations to filterListstatic List<Annotation> getAllDeclaredAnnotations(Class<?> type, Predicate<Annotation>... annotationsToFilter)
type - the specified typeannotationsToFilter - the annotations to filterListstatic List<Annotation> getMetaAnnotations(Class<? extends Annotation> annotationType, Predicate<Annotation>... metaAnnotationsToFilter)
annotationType - the annotation typemetaAnnotationsToFilter - the meta annotations to filterListstatic List<Annotation> getAllMetaAnnotations(Class<? extends Annotation> annotationType, Predicate<Annotation>... annotationsToFilter)
annotation typeannotationType - the annotation typeannotationsToFilter - the annotations to filterListstatic <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement, String annotationClassName)
A - the required type of annotationannotatedElement - the annotated elementannotationClassName - the class name of annotationannotation, or nullstatic <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType)
A - the required type of annotationannotatedElement - the annotated elementannotationType - the type of annotationannotation, or nullstatic <A extends Annotation> List<A> findMetaAnnotations(Class<? extends Annotation> annotationType, Class<A> metaAnnotationType)
annotation type by meta annotation typeA - the type of required annotationannotationType - the annotation typemetaAnnotationType - the meta annotation typeempty liststatic <A extends Annotation> List<A> findMetaAnnotations(AnnotatedElement annotatedElement, Class<A> metaAnnotationType)
A - the type of required annotationannotatedElement - the annotated elementmetaAnnotationType - the meta annotation typeempty liststatic <A extends Annotation> A findMetaAnnotation(AnnotatedElement annotatedElement, String metaAnnotationClassName)
A - the type of required annotationannotatedElement - the annotated elementmetaAnnotationClassName - the class name of meta annotationfindMetaAnnotation(Class, Class)static <A extends Annotation> A findMetaAnnotation(Class<? extends Annotation> annotationType, Class<A> metaAnnotationType)
A - the type of required annotationannotationType - the annotation typemetaAnnotationType - the meta annotation typeCollectionUtils.first(Collection) matched result, return null.
If it requires more result, please consider to use findMetaAnnotations(Class, Class)findMetaAnnotations(Class, Class)static <A extends Annotation> A findMetaAnnotation(AnnotatedElement annotatedElement, Class<A> metaAnnotationType)
A - the type of required annotationannotatedElement - the annotated elementmetaAnnotationType - the meta annotation typeCollectionUtils.first(Collection) matched result, return null.
If it requires more result, please consider to use findMetaAnnotations(AnnotatedElement, Class)findMetaAnnotations(AnnotatedElement, Class)static boolean isAnnotationPresent(Class<?> type, boolean matchAll, Class<? extends Annotation>... annotationTypes)
type - the annotated typematchAll - If true, checking all annotation types are present or not, or match anyannotationTypes - the specified annotation typestrue, or falsestatic boolean isAnnotationPresent(Class<?> type, Class<? extends Annotation> annotationType)
type - the annotated typeannotationType - the class of annotationtrue, or falsestatic boolean isAnnotationPresent(AnnotatedElement annotatedElement, String annotationClassName)
annotatedElement - the annotated elementannotationClassName - the class name of annotationtruestatic boolean isAnnotationPresent(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType)
annotatedElement - the annotated elementannotationType - the class of annotationtruestatic boolean isAllAnnotationPresent(Class<?> type, Class<? extends Annotation>... annotationTypes)
type - the annotated typeannotationTypes - the specified annotation typestrue, or falsestatic boolean isAnyAnnotationPresent(Class<?> type, Class<? extends Annotation>... annotationTypes)
type - the annotated typeannotationTypes - the specified annotation typestrueCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.