Interface AnnotationValue

All Known Subinterfaces:
AnnotationValue.OfAnnotation, AnnotationValue.OfArray, AnnotationValue.OfBoolean, AnnotationValue.OfByte, AnnotationValue.OfChar, AnnotationValue.OfClass, AnnotationValue.OfConstant, AnnotationValue.OfDouble, AnnotationValue.OfEnum, AnnotationValue.OfFloat, AnnotationValue.OfInt, AnnotationValue.OfLong, AnnotationValue.OfShort, AnnotationValue.OfString

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.

Sealed Class Hierarchy Graph:
Sealed class hierarchy graph for AnnotationValueSealed class hierarchy graph for AnnotationValue
Since:
24
See Also:
  • Field Details

  • Method Details

    • tag

      int 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.
      API Note:
      TAG_-prefixed constants in this class, such as TAG_INT, describe the possible return values of this method. The return type is int for consistency with union indicator items in other union structures in the class file format.
      Returns:
      the tag character for this value as per JVMS 4.7.16.1
    • ofEnum

      static AnnotationValue.OfEnum ofEnum(Utf8Entry className, Utf8Entry constantName)
      Returns an enum value for an element-value pair.
      Parameters:
      className - the descriptor string of the enum class
      constantName - the name of the enum constant
      Returns:
      an enum value for an element-value pair
    • ofEnum

      static AnnotationValue.OfEnum ofEnum(ClassDesc className, String constantName)
      Returns an enum value for an element-value pair.
      Parameters:
      className - the descriptor of the enum class
      constantName - the name of the enum constant
      Returns:
      an enum value for an element-value pair
    • ofClass

      static AnnotationValue.OfClass ofClass(Utf8Entry className)
      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

      static AnnotationValue.OfClass ofClass(ClassDesc className)
      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

      static AnnotationValue.OfString ofString(Utf8Entry value)
      Returns a string value for an element-value pair.
      Parameters:
      value - the string
      Returns:
      a string value for an element-value pair
    • ofString

      static AnnotationValue.OfString ofString(String value)
      Returns a string value for an element-value pair.
      Parameters:
      value - the string
      Returns:
      a string value for an element-value pair
    • ofDouble

      static AnnotationValue.OfDouble ofDouble(DoubleEntry value)
      Returns a double value for an element-value pair.
      Parameters:
      value - the double value
      Returns:
      a double value for an element-value pair
    • ofDouble

      static AnnotationValue.OfDouble ofDouble(double value)
      Returns a double value for an element-value pair.
      Parameters:
      value - the double value
      Returns:
      a double value for an element-value pair
    • ofFloat

      static AnnotationValue.OfFloat ofFloat(FloatEntry value)
      Returns a float value for an element-value pair.
      Parameters:
      value - the float value
      Returns:
      a float value for an element-value pair
    • ofFloat

      static AnnotationValue.OfFloat ofFloat(float value)
      Returns a float value for an element-value pair.
      Parameters:
      value - the float value
      Returns:
      a float value for an element-value pair
    • ofLong

      static AnnotationValue.OfLong ofLong(LongEntry value)
      Returns a long value for an element-value pair.
      Parameters:
      value - the long value
      Returns:
      a long value for an element-value pair
    • ofLong

      static AnnotationValue.OfLong ofLong(long value)
      Returns a long value for an element-value pair.
      Parameters:
      value - the long value
      Returns:
      a long value for an element-value pair
    • ofInt

      static AnnotationValue.OfInt ofInt(IntegerEntry value)
      Returns an int value for an element-value pair.
      Parameters:
      value - the int value
      Returns:
      an int value for an element-value pair
    • ofInt

      static AnnotationValue.OfInt ofInt(int value)
      Returns an int value for an element-value pair.
      Parameters:
      value - the int value
      Returns:
      an int value for an element-value pair
    • ofShort

      static AnnotationValue.OfShort ofShort(IntegerEntry value)
      Returns a short value for an element-value pair.
      Parameters:
      value - the short value
      Returns:
      a short value for an element-value pair
    • ofShort

      static AnnotationValue.OfShort ofShort(short value)
      Returns a short value for an element-value pair.
      Parameters:
      value - the short value
      Returns:
      a short value for an element-value pair
    • ofChar

      static AnnotationValue.OfChar ofChar(IntegerEntry value)
      Returns a char value for an element-value pair.
      Parameters:
      value - the char value
      Returns:
      a char value for an element-value pair
    • ofChar

      static AnnotationValue.OfChar ofChar(char value)
      Returns a char value for an element-value pair.
      Parameters:
      value - the char value
      Returns:
      a char value for an element-value pair
    • ofByte

      static AnnotationValue.OfByte ofByte(IntegerEntry value)
      Returns a byte value for an element-value pair.
      Parameters:
      value - the byte value
      Returns:
      a byte value for an element-value pair
    • ofByte

      static AnnotationValue.OfByte ofByte(byte value)
      Returns a byte value for an element-value pair.
      Parameters:
      value - the byte value
      Returns:
      a byte value for an element-value pair
    • ofBoolean

      static AnnotationValue.OfBoolean ofBoolean(IntegerEntry value)
      Returns a boolean value for an element-value pair.
      Parameters:
      value - the boolean value
      Returns:
      a boolean value for an element-value pair
    • ofBoolean

      static AnnotationValue.OfBoolean ofBoolean(boolean value)
      Returns a boolean value for an element-value pair.
      Parameters:
      value - the boolean value
      Returns:
      a boolean value for an element-value pair
    • ofAnnotation

      static AnnotationValue.OfAnnotation ofAnnotation(Annotation value)
      Returns an annotation value for an element-value pair.
      Parameters:
      value - the annotation
      Returns:
      an annotation value for an element-value pair
    • ofArray

      static AnnotationValue.OfArray ofArray(List<AnnotationValue> values)
      Returns an array value for an element-value pair.
      API Note:
      See values() for conventions on array values derived from Java source code.
      Parameters:
      values - the array elements
      Returns:
      an array value for an element-value pair
    • ofArray

      static AnnotationValue.OfArray ofArray(AnnotationValue... values)
      Returns an array value for an element-value pair.
      API Note:
      See values() for conventions on array values derived from Java source code.
      Parameters:
      values - the array elements
      Returns:
      an array value for an element-value pair
    • of

      static AnnotationValue of(Object value)
      Returns an annotation element. The value 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 the value parameter is not a primitive, a wrapper of primitive, a String, a ClassDesc, an enum constant, or an array of one of these.