Enum AnnotationRetention
- java.lang.Object
-
- java.lang.Enum<AnnotationRetention>
-
- net.bytebuddy.implementation.attribute.AnnotationRetention
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnnotationRetention>
public enum AnnotationRetention extends java.lang.Enum<AnnotationRetention>
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 aAnnotationValueFilter
.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
enabled
true
if annotation retention is enabled.
-
Constructor Summary
Constructors Modifier Constructor Description private
AnnotationRetention(boolean enabled)
Creates an annotation retention strategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isEnabled()
Returnstrue
if annotation retention is enabled.static AnnotationRetention
of(boolean enabled)
Resolves an annotation retention from a boolean value.static AnnotationRetention
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static AnnotationRetention[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ENABLED
public static final AnnotationRetention ENABLED
Enables annotation retention, i.e. annotations within an existing class files are preserved as they are.
-
DISABLED
public static final AnnotationRetention DISABLED
Disables annotation retention, i.e. annotations within an existing class files are discarded.
-
-
Method Detail
-
values
public static AnnotationRetention[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (AnnotationRetention c : AnnotationRetention.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static AnnotationRetention valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
of
public static AnnotationRetention of(boolean enabled)
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.
-
-