public abstract class AnnotationUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
findAnnotation(AnnotatedElement element,
Class<T> annotationType)
Deprecated.
This method does not consider overrides of attributes using meta-annotations. Use
findAnnotationAttributes(AnnotatedElement, Class) instead. |
static Annotation |
findAnnotation(AnnotatedElement element,
String annotationType)
Deprecated.
This method does not consider overrides of attributes using meta-annotations. Use
findAnnotationAttributes(AnnotatedElement, String) instead. |
static Optional<Map<String,Object>> |
findAnnotationAttributes(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Find the attributes of an annotation of type
annotationType on the given element . |
static Optional<Map<String,Object>> |
findAnnotationAttributes(AnnotatedElement element,
String annotationName)
Find the attributes of an annotation with given
annotationName on the given element . |
static boolean |
isAnnotationPresent(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Indicates whether an annotation of given
annotationType is present on the given element ,
considering that the given annotationType may be present as a meta annotation on any other annotation
on that element. |
static boolean |
isAnnotationPresent(AnnotatedElement element,
String annotationType)
Indicates whether an annotation with given
annotationType is present on the given element ,
considering that the given annotationType may be present as a meta annotation on any other annotation
on that element. |
@Deprecated public static <T extends Annotation> T findAnnotation(AnnotatedElement element, Class<T> annotationType)
findAnnotationAttributes(AnnotatedElement, Class)
instead.annotationType
on the given element
, considering that the
given annotationType
may be present as a meta annotation on any other annotation on that element.T
- The generic type of the annotationelement
- The element to inspectannotationType
- The type of annotation to findnull
if no such annotation is present.@Deprecated public static Annotation findAnnotation(AnnotatedElement element, String annotationType)
findAnnotationAttributes(AnnotatedElement, String)
instead.annotationType
as String on the given element
,
considering that the given annotationType
may be present as a meta annotation on any other
annotation on that element.element
- The element to inspectannotationType
- The type of annotation as String to findnull
if no such annotation is present.public static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
is present on the given element
,
considering that the given annotationType
may be present as a meta annotation on any other annotation
on that element.element
- The element to inspectannotationType
- The type of annotation to findtrue
if such annotation is present.public static boolean isAnnotationPresent(AnnotatedElement element, String annotationType)
annotationType
is present on the given element
,
considering that the given annotationType
may be present as a meta annotation on any other annotation
on that element.element
- The element to inspectannotationType
- The name of the annotation to findtrue
if such annotation is present.public static Optional<Map<String,Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName)
annotationName
on the given element
. The returned
optional has a value present if the annotation has been found, either directly on the element
, or as a
meta-annotation.
The map of attributes contains all the attributes found on the annotation, as well as attributes of any annotations on which the targeted annotation was placed (directly, or indirectly).
element
- The element for find the annotation onannotationName
- The name of the annotation to findpublic static Optional<Map<String,Object>> findAnnotationAttributes(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
on the given element
. The returned
optional has a value present if the annotation has been found, either directly on the element
, or as a
meta-annotation.
The map of attributes contains all the attributes found on the annotation, as well as attributes of any
annotations on which the targeted annotation was placed (directly, or indirectly). Note that the value
property of annotations is reported as the simple class name (lowercase first character) of the annotation. This
allows specific attribute overrides for annotations that have multiple meta-annotation with the value
property.
element
- The element for find the annotation onannotationType
- The type of the annotation to findCopyright © 2010–2018. All rights reserved.