Interface AnnotationElement
public sealed interface AnnotationElement
Models an element-value pair in the
element_value_pairs table in the annotation structure defined in JVMS §4.7.16 or the type_annotation structure defined in JVMS §4.7.20. Two AnnotationElement objects should be compared using the equals method.
- See Java Virtual Machine Specification:
- 4.7.16.1 The
element_valuestructure
- Since:
- 24
- See Also:
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Utf8Entry |
name() |
Returns the element name. |
static AnnotationElement |
of |
Returns an element-value pair. |
static AnnotationElement |
of |
Returns an element-value pair. |
static AnnotationElement |
ofAnnotation |
Returns an element-value pair for an annotation-valued element. |
static AnnotationElement |
ofArray |
Returns an element-value pair for an array-valued element. |
static AnnotationElement |
ofBoolean |
Returns an element-value pair for a boolean-valued element. |
static AnnotationElement |
ofByte |
Returns an element-value pair for a byte-valued element. |
static AnnotationElement |
ofChar |
Returns an element-value pair for a char-valued element. |
static AnnotationElement |
ofClass |
Returns an element-value pair for a class-valued element. |
static AnnotationElement |
ofDouble |
Returns an element-value pair for a double-valued element. |
static AnnotationElement |
ofFloat |
Returns an element-value pair for a float-valued element. |
static AnnotationElement |
ofInt |
Returns an element-value pair for an int-valued element. |
static AnnotationElement |
ofLong |
Returns an element-value pair for a long-valued element. |
static AnnotationElement |
ofShort |
Returns an element-value pair for a short-valued element. |
static AnnotationElement |
ofString |
Returns an element-value pair for a string-valued element. |
AnnotationValue |
value() |
Returns the element value. |
Method Details
name
Utf8Entry name()
Returns the element name.
value
AnnotationValue value()
Returns the element value.
- Returns:
- the element value
of
static AnnotationElement of(Utf8Entry name, AnnotationValue value)
Returns an element-value pair.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair
of
static AnnotationElement of(String name, AnnotationValue value)
Returns an element-value pair.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair
ofClass
static AnnotationElement ofClass(String name, ClassDesc value)
Returns an element-value pair for a class-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a class-valued element
- See Also:
ofString
static AnnotationElement ofString(String name, String value)
Returns an element-value pair for a string-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a string-valued element
- See Also:
ofLong
static AnnotationElement ofLong(String name, long value)
Returns an element-value pair for a long-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a long-valued element
- See Also:
ofInt
static AnnotationElement ofInt(String name, int value)
Returns an element-value pair for an int-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for an int-valued element
- See Also:
ofChar
static AnnotationElement ofChar(String name, char value)
Returns an element-value pair for a char-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a char-valued element
- See Also:
ofShort
static AnnotationElement ofShort(String name, short value)
Returns an element-value pair for a short-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a short-valued element
- See Also:
ofByte
static AnnotationElement ofByte(String name, byte value)
Returns an element-value pair for a byte-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a byte-valued element
- See Also:
ofBoolean
static AnnotationElement ofBoolean(String name, boolean value)
Returns an element-value pair for a boolean-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a boolean-valued element
- See Also:
ofDouble
static AnnotationElement ofDouble(String name, double value)
Returns an element-value pair for a double-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a double-valued element
- See Also:
ofFloat
static AnnotationElement ofFloat(String name, float value)
Returns an element-value pair for a float-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for a float-valued element
- See Also:
ofAnnotation
static AnnotationElement ofAnnotation(String name, Annotation value)
Returns an element-value pair for an annotation-valued element.
- Parameters:
-
name- the name of the key -
value- the associated value - Returns:
- an element-value pair for an annotation-valued element
- See Also:
ofArray
static AnnotationElement ofArray(String name, AnnotationValue... values)
Returns an element-value pair for an array-valued element.
- Parameters:
-
name- the name of the key -
values- the associated values - Returns:
- an element-value pair for an array-valued element
- Throws:
-
IllegalArgumentException- if the number of associated values exceeds the limit ofu2 - See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.