Name
ElementType
Synopsis
The
constants
declared by this enumerated type represent the types of program
elements that can be annotated. The value
of an
@Target
annotation is an array of
ElementType
constants. Most of the
constants
have obvious meanings, but some require additional explanation.
TYPE
represents a class, interface, enumerated
type, or annotation type. ANNOTATION_TYPE
represents only annotation types and is used for meta-annotations.
FIELD
includes enumerated constants, and
PARAMETER
includes both method parameters and
catch
clause parameters. Note that the
METHOD
and CONSTRUCTOR
are
distinct constants.
Figure 10-77. java.lang.annotation.ElementType
public enum ElementType { // Enumerated Constants TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE; // Public Class Methods public static ElementType valueOf(String name); public static final ElementType[ ] values( ); }
Returned By
Target.value( )
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.