Enum Class AnnotationRetention
- All Implemented Interfaces:
Serializable
,Comparable<AnnotationRetention>
,Constable
An annotation retention strategy decides if annotations that are contained within a class file are preserved upon redefining
or rebasing a method. When annotations are retained, it is important not to define annotations explicitly that are already
defined. When annotations are retained, they are retained in their original format, i.e. default values that were not included
in the class file are not added or skipped as determined by a
AnnotationValueFilter
.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
true
if annotation retention is enabled. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
AnnotationRetention
(boolean enabled) Creates an annotation retention strategy. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if annotation retention is enabled.static AnnotationRetention
of
(boolean enabled) Resolves an annotation retention from a boolean value.static AnnotationRetention
Returns the enum constant of this class with the specified name.static AnnotationRetention[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ENABLED
Enables annotation retention, i.e. annotations within an existing class files are preserved as they are. -
DISABLED
Disables annotation retention, i.e. annotations within an existing class files are discarded.
-
-
Field Details
-
enabled
private final boolean enabledtrue
if annotation retention is enabled.
-
-
Constructor Details
-
AnnotationRetention
private AnnotationRetention(boolean enabled) Creates an annotation retention strategy.- Parameters:
enabled
-true
if annotation retention is enabled.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
of
Resolves an annotation retention from a boolean value.- Parameters:
enabled
-true
if annotation retention is enabled.- Returns:
- An enabled annotation retention if the value is
true
.
-
isEnabled
public boolean isEnabled()Returnstrue
if annotation retention is enabled.- Returns:
true
if annotation retention is enabled.
-