Name
AnnotatedElement
Synopsis
This
interface is implemented by the
classes representing program elements that can be annotated in
Java
5.0: java.lang.Class,
java.lang.Package, Method,
Constructor, and Field. The
methods of this interface allow you to test for the presence of a
specific annotation, query an annotation object of a specific type,
or query all annotations present on an annotated element.
getDeclaredAnnotations(
)
differs from getAnnotations(
) in that it does not include inherited annotations. (See
the java.lang.annotation.Inherited
meta-annotation.) If no annotations are present,
getAnnotations( ) and
getDeclaredAnnotations( ) return an array of
length zero rather than null. It is safe to modify
the arrays returned by these methods.
See also the getParameterAnnotations( ) methods of
Method and Constructor, which
provide access to annotations on method parameters.
public interface AnnotatedElement { // Public Instance Methods <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> annotationType); java.lang.annotation.Annotation[ ] getAnnotations( ); java.lang.annotation.Annotation[ ] getDeclaredAnnotations( ); boolean isAnnotationPresent(Class<? extends java.lang.annotation.Annotation> annotationType); }
Implementations
Class, Package,
AccessibleObject