Package java.lang.reflect
Interface AnnotatedElement
-
- All Known Implementing Classes:
AbstractMethod,AccessibleObject,Class,Constructor,Field,Method,Package
public interface AnnotatedElementThis interface provides reflective access to annotation information.- Since:
- 1.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends Annotation>
TgetAnnotation(Class<T> annotationType)Returns, for this element, the annotation with the specified type, ornullif no annotation with the specified type is present (including inherited annotations).Annotation[]getAnnotations()Returns, for this element, an array containing all annotations (including inherited annotations).Annotation[]getDeclaredAnnotations()Returns, for this element, all annotations that are explicitly declared (not inherited).booleanisAnnotationPresent(Class<? extends Annotation> annotationType)Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).
-
-
-
Method Detail
-
getAnnotation
<T extends Annotation> T getAnnotation(Class<T> annotationType)
Returns, for this element, the annotation with the specified type, ornullif no annotation with the specified type is present (including inherited annotations).- Parameters:
annotationType- the type of the annotation to search for- Returns:
- the annotation with the specified type or
null - Throws:
NullPointerException- ifannotationTypeisnull
-
getAnnotations
Annotation[] getAnnotations()
Returns, for this element, an array containing all annotations (including inherited annotations). If there are no annotations present, this method returns a zero length array.- Returns:
- an array of all annotations for this element
-
getDeclaredAnnotations
Annotation[] getDeclaredAnnotations()
Returns, for this element, all annotations that are explicitly declared (not inherited). If there are no declared annotations present, this method returns a zero length array.- Returns:
- an array of annotations declared for this element
-
isAnnotationPresent
boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).- Parameters:
annotationType- the type of the annotation to search for- Returns:
trueif the annotation exists,falseotherwise- Throws:
NullPointerException- ifannotationTypeisnull
-
-