Represents an annotated element of the program currently running in this
JVM. This interface allows annotations to be read reflectively. All
annotations returned by methods in this interface are serializable.
If an annotation object returned by a method in this interface
contains (directly or indirectly) one or more Class members
that refer to a class that is not accessible in this JVM, attempting
to read the class by calling the relevant Class-returning
method on the returned annotation (or an annotation referred to by
that annotation) will cause a TypeNotPresentException
to be thrown.
Method Summary | ||
---|---|---|
|
getAnnotation(Class<T> annotationType)
Returns this element's annotation for the specified type if such an annotation is present, else null. |
|
java.lang.annotation.Annotation[] |
getAnnotations()
Returns all annotations present on this element. |
|
java.lang.annotation.Annotation[] |
getDeclaredAnnotations()
Returns all annotations that are directly present on this element. |
|
boolean |
isAnnotationPresent(Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if an annotation for the specified type is present on this element, else false. |
Method Detail |
---|
boolean isAnnotationPresent(Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
- the Class object corresponding to the
annotation type
NullPointerException
- if annotationType is null<T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> annotationType)
annotationType
- the Class object corresponding to the
annotation type
NullPointerException
- if annotationType is nulljava.lang.annotation.Annotation[] getAnnotations()
java.lang.annotation.Annotation[] getDeclaredAnnotations()