Interface AnnotationValue
- All Known Subinterfaces:
AnnotationValue.OfAnnotationPREVIEW
,AnnotationValue.OfArrayPREVIEW
,AnnotationValue.OfBooleanPREVIEW
,AnnotationValue.OfBytePREVIEW
,AnnotationValue.OfCharPREVIEW
,AnnotationValue.OfClassPREVIEW
,AnnotationValue.OfConstantPREVIEW
,AnnotationValue.OfDoublePREVIEW
,AnnotationValue.OfEnumPREVIEW
,AnnotationValue.OfFloatPREVIEW
,AnnotationValue.OfIntPREVIEW
,AnnotationValue.OfLongPREVIEW
,AnnotationValue.OfShortPREVIEW
,AnnotationValue.OfStringPREVIEW
public sealed interface AnnotationValue
permits AnnotationValue.OfAnnotationPREVIEW, AnnotationValue.OfArrayPREVIEW, AnnotationValue.OfConstantPREVIEW, AnnotationValue.OfClassPREVIEW, AnnotationValue.OfEnumPREVIEW
AnnotationValue
is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models an
element_value
structure, or a value of an element-value
pair of an annotation, as defined in JVMS 4.7.16.1.
Two AnnotationValue
objects should be compared using the equals
method.
- Since:
- 22
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Preview.Models an annotation value of an element-value pair.static interface
Preview.Models an array value of an element-value pair.static interface
Preview.Models a boolean value of an element-value pair.static interface
Preview.Models a byte value of an element-value pair.static interface
Preview.Models a char value of an element-value pair.static interface
Preview.Models a class value of an element-value pair.static interface
Preview.Models a constant value of an element-value pair.static interface
Preview.Models a double value of an element-value pair.static interface
Preview.Models an enum value of an element-value pair.static interface
Preview.Models a float value of an element-value pair.static interface
Preview.Models an int value of an element-value pair.static interface
Preview.Models a long value of an element-value pair.static interface
Preview.Models a short value of an element-value pair.static interface
Preview.Models a string value of an element-value pair. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnnotationValuePREVIEW
Returns an annotation element.ofAnnotation
(AnnotationPREVIEW value) Returns an annotation value for an element-value pair.ofArray
(AnnotationValuePREVIEW... values) Returns an array value for an element-value pair.ofArray
(List<AnnotationValuePREVIEW> values) Returns an array value for an element-value pair.ofBoolean
(boolean value) Returns a boolean value for an element-value pair.ofBoolean
(IntegerEntryPREVIEW value) Returns a boolean value for an element-value pair.ofByte
(byte value) Returns a byte value for an element-value pair.ofByte
(IntegerEntryPREVIEW value) Returns a byte value for an element-value pair.ofChar
(char value) Returns a char value for an element-value pair.ofChar
(IntegerEntryPREVIEW value) Returns a char value for an element-value pair.Returns a class value for an element-value pair.Returns a class value for an element-value pair.ofDouble
(double value) Returns a double value for an element-value pair.ofDouble
(DoubleEntryPREVIEW value) Returns a double value for an element-value pair.Returns an enum value for an element-value pair.Returns an enum value for an element-value pair.ofFloat
(float value) Returns a float value for an element-value pair.ofFloat
(FloatEntryPREVIEW value) Returns a float value for an element-value pair.static AnnotationValue.OfIntPREVIEW
ofInt
(int value) Returns an int value for an element-value pair.static AnnotationValue.OfIntPREVIEW
ofInt
(IntegerEntryPREVIEW value) Returns an int value for an element-value pair.ofLong
(long value) Returns a long value for an element-value pair.Returns a long value for an element-value pair.ofShort
(short value) Returns a short value for an element-value pair.ofShort
(IntegerEntryPREVIEW value) Returns a short value for an element-value pair.Returns a string value for an element-value pair.Returns a string value for an element-value pair.char
tag()
Returns the tag character for this value as per JVMS 4.7.16.1.
-
Field Details
-
TAG_BYTE
static final int TAG_BYTE- See Also:
-
TAG_CHAR
static final int TAG_CHAR- See Also:
-
TAG_DOUBLE
static final int TAG_DOUBLE- See Also:
-
TAG_FLOAT
static final int TAG_FLOAT- See Also:
-
TAG_INT
static final int TAG_INT- See Also:
-
TAG_LONG
static final int TAG_LONG- See Also:
-
TAG_SHORT
static final int TAG_SHORT- See Also:
-
TAG_BOOLEAN
static final int TAG_BOOLEAN- See Also:
-
TAG_STRING
static final int TAG_STRING- See Also:
-
TAG_ENUM
static final int TAG_ENUM- See Also:
-
TAG_CLASS
static final int TAG_CLASS- See Also:
-
TAG_ANNOTATION
static final int TAG_ANNOTATION- See Also:
-
TAG_ARRAY
static final int TAG_ARRAY- See Also:
-
-
Method Details
-
tag
char tag()Returns the tag character for this value as per JVMS 4.7.16.1. The tag characters have a one-to-one mapping to the types of annotation element values. -
ofEnum
static AnnotationValue.OfEnumPREVIEW ofEnum(Utf8EntryPREVIEW className, Utf8EntryPREVIEW constantName) Returns an enum value for an element-value pair.- Parameters:
className
- the descriptor string of the enum classconstantName
- the name of the enum constant- Returns:
- an enum value for an element-value pair
-
ofEnum
Returns an enum value for an element-value pair.- Parameters:
className
- the descriptor of the enum classconstantName
- the name of the enum constant- Returns:
- an enum value for an element-value pair
-
ofClass
Returns a class value for an element-value pair.- Parameters:
className
- the descriptor string of the class- Returns:
- a class value for an element-value pair
-
ofClass
Returns a class value for an element-value pair.- Parameters:
className
- the descriptor of the class- Returns:
- a class value for an element-value pair
-
ofString
Returns a string value for an element-value pair.- Parameters:
value
- the string- Returns:
- a string value for an element-value pair
-
ofString
Returns a string value for an element-value pair.- Parameters:
value
- the string- Returns:
- a string value for an element-value pair
-
ofDouble
Returns a double value for an element-value pair.- Parameters:
value
- the double value- Returns:
- a double value for an element-value pair
-
ofDouble
Returns a double value for an element-value pair.- Parameters:
value
- the double value- Returns:
- a double value for an element-value pair
-
ofFloat
Returns a float value for an element-value pair.- Parameters:
value
- the float value- Returns:
- a float value for an element-value pair
-
ofFloat
Returns a float value for an element-value pair.- Parameters:
value
- the float value- Returns:
- a float value for an element-value pair
-
ofLong
Returns a long value for an element-value pair.- Parameters:
value
- the long value- Returns:
- a long value for an element-value pair
-
ofLong
Returns a long value for an element-value pair.- Parameters:
value
- the long value- Returns:
- a long value for an element-value pair
-
ofInt
Returns an int value for an element-value pair.- Parameters:
value
- the int value- Returns:
- an int value for an element-value pair
-
ofInt
Returns an int value for an element-value pair.- Parameters:
value
- the int value- Returns:
- an int value for an element-value pair
-
ofShort
Returns a short value for an element-value pair.- Parameters:
value
- the short value- Returns:
- a short value for an element-value pair
-
ofShort
Returns a short value for an element-value pair.- Parameters:
value
- the short value- Returns:
- a short value for an element-value pair
-
ofChar
Returns a char value for an element-value pair.- Parameters:
value
- the char value- Returns:
- a char value for an element-value pair
-
ofChar
Returns a char value for an element-value pair.- Parameters:
value
- the char value- Returns:
- a char value for an element-value pair
-
ofByte
Returns a byte value for an element-value pair.- Parameters:
value
- the byte value- Returns:
- a byte value for an element-value pair
-
ofByte
Returns a byte value for an element-value pair.- Parameters:
value
- the byte value- Returns:
- a byte value for an element-value pair
-
ofBoolean
Returns a boolean value for an element-value pair.- Parameters:
value
- the boolean value- Returns:
- a boolean value for an element-value pair
-
ofBoolean
Returns a boolean value for an element-value pair.- Parameters:
value
- the boolean value- Returns:
- a boolean value for an element-value pair
-
ofAnnotation
Returns an annotation value for an element-value pair.- Parameters:
value
- the annotation- Returns:
- an annotation value for an element-value pair
-
ofArray
Returns an array value for an element-value pair. -
ofArray
Returns an array value for an element-value pair. -
of
Returns an annotation element. Thevalue
parameter must be a primitive, a wrapper of primitive, a String, a ClassDesc, an enum constant, or an array of one of these.- Parameters:
value
- the annotation value- Returns:
- an annotation element
- Throws:
IllegalArgumentException
- when thevalue
parameter is not a primitive, a wrapper of primitive, a String, a ClassDesc, an enum constant, or an array of one of these.
-
AnnotationValue
when preview features are enabled.