Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page