public sealed interface AnnotationElement
Models an element-value pair in the
element_value_pairs
table in the annotation structure defined in JVMS
or the type_annotation structure defined
in JVMS .
Two AnnotationElement objects should be compared using the
equals method.
- Since:
- 24
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionname()Returns the element name.static AnnotationElementof(Utf8Entry name, AnnotationValue value) Returns an element-value pair.static AnnotationElementof(String name, AnnotationValue value) Returns an element-value pair.static AnnotationElementofAnnotation(String name, Annotation value) Returns an element-value pair for an annotation-valued element.static AnnotationElementofArray(String name, AnnotationValue... values) Returns an element-value pair for an array-valued element.static AnnotationElementReturns an element-value pair for a boolean-valued element.static AnnotationElementReturns an element-value pair for a byte-valued element.static AnnotationElementReturns an element-value pair for a char-valued element.static AnnotationElementReturns an element-value pair for a class-valued element.static AnnotationElementReturns an element-value pair for a double-valued element.static AnnotationElementReturns an element-value pair for a float-valued element.static AnnotationElementReturns an element-value pair for an int-valued element.static AnnotationElementReturns an element-value pair for a long-valued element.static AnnotationElementReturns an element-value pair for a short-valued element.static AnnotationElementReturns an element-value pair for a string-valued element.value()Returns the element value.
-
Method Details
-
name
Utf8Entry name()Returns the element name.- API Note:
- In Java source code, by convention, the name of the sole element in a
single-element annotation interface is
value. (JLS ) This is the case for single-element annotations (JLS ) and container annotations for multiple annotations (JLS ). - Returns:
- the element name
-
value
AnnotationValue value()Returns the element value.- Returns:
- the element value
-
of
Returns an element-value pair.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair
-
of
Returns an element-value pair.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair
-
ofClass
Returns an element-value pair for a class-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a class-valued element
- See Also:
-
ofString
Returns an element-value pair for a string-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a string-valued element
- See Also:
-
ofLong
Returns an element-value pair for a long-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a long-valued element
- See Also:
-
ofInt
Returns an element-value pair for an int-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for an int-valued element
- See Also:
-
ofChar
Returns an element-value pair for a char-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a char-valued element
- See Also:
-
ofShort
Returns an element-value pair for a short-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a short-valued element
- See Also:
-
ofByte
Returns an element-value pair for a byte-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a byte-valued element
- See Also:
-
ofBoolean
Returns an element-value pair for a boolean-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a boolean-valued element
- See Also:
-
ofDouble
Returns an element-value pair for a double-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a double-valued element
- See Also:
-
ofFloat
Returns an element-value pair for a float-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for a float-valued element
- See Also:
-
ofAnnotation
Returns an element-value pair for an annotation-valued element.- Parameters:
name- the name of the keyvalue- the associated value- Returns:
- an element-value pair for an annotation-valued element
- See Also:
-
ofArray
Returns an element-value pair for an array-valued element.- Parameters:
name- the name of the keyvalues- 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:
-