java.lang.annotation

Class RetentionPolicy

public class RetentionPolicy extends Enum<RetentionPolicy>

This enum is used to control the lifetime of an annotation.

Since: 1.5

See Also: Retention

Field Summary
static RetentionPolicyCLASS
Indicates that the annotation should be stored in class files.
static RetentionPolicyRUNTIME
Indicates that the annotation should be available at runtime.
static RetentionPolicySOURCE
Indicates that the annotation should only be available when parsing the source code.
static List<RetentionPolicy>VALUES
An immutable list containing the values comprising this enum class in the order they're declared.
Method Summary
List<RetentionPolicy>family()
Returns an immutable list containing the values comprising this enum class in the order they're declared.
static RetentionPolicyvalueOf(String name)
Static factory to return the enum constant pertaining to the given string name.

Field Detail

CLASS

public static final RetentionPolicy CLASS
Indicates that the annotation should be stored in class files.

RUNTIME

public static final RetentionPolicy RUNTIME
Indicates that the annotation should be available at runtime.

SOURCE

public static final RetentionPolicy SOURCE
Indicates that the annotation should only be available when parsing the source code.

VALUES

public static final List<RetentionPolicy> VALUES
An immutable list containing the values comprising this enum class in the order they're declared. This field may be used to iterate over the constants as follows:
for(RetentionPolicy c : RetentionPolicy.VALUES)
    System.out.println(c);

Method Detail

family

public final List<RetentionPolicy> family()
Returns an immutable list containing the values comprising this enum class in the order they're declared. This instance method simply returns VALUES. Few programmers should have any need to use this method. It is provided for use by sophisticated enum-based data structures to prevent the need for reflective access to VALUES.

Returns: an immutable list containing the values comprising this enum class, in the order they're declared.

valueOf

public static final RetentionPolicy valueOf(String name)
Static factory to return the enum constant pertaining to the given string name. The string must match exactly an identifier used to declare an enum constant in this type.

Throws: IllegalArgumentException if this enum class has no constant with the specified name.