Top Description Inners Fields Methods
jakarta.enterprise.lang.model

public Interface AnnotationMember

Imports
jakarta.enterprise.lang.model.declarations.ClassInfo, jakarta.enterprise.lang.model.types.Type, java.util.List

The value of an annotation member. Annotation member values are of several kinds: The kind() method returns the kind of this annotation member value. The is* methods (such as isBoolean()) allow checking if this annotation member value is of given kind. The as* methods (such as asBoolean()) allow "unwrapping" this annotation member value, if it is of the corresponding kind.

Note that the as* methods do not perform type conversion, so if this annotation member value is an int, calling asLong() will throw an exception.

Implementations of this interface are required to define the equals and hashCode methods. Implementations of this interface are encouraged to define the toString method such that it returns a text resembling the corresponding Java™ syntax.

There is no guarantee that any particular annotation member, represented by an implementation of this interface, will always be represented by the same object. This includes natural singletons such as boolean values. Instances should always be compared using equals.

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
AnnotationMember.Kind

The kind of the annotation member value.

Field Summary

Modifier and TypeField and Description
public static final String
VALUE

Name of the commonly used value() annotation member.

Method Summary

Modifier and TypeMethod and Description
public List<AnnotationMember>

Returns:

an immutable list of AnnotationMembers
asArray
()

Returns this array value as an immutable List of AnnotationMembers.

public boolean

Returns:

the boolean value
asBoolean
()

Returns this value as a boolean.

public byte

Returns:

the byte value
asByte
()

Returns this value as a byte.

public char

Returns:

the char value
asChar
()

Returns this value as a char.

public double

Returns:

the double value
asDouble
()

Returns this value as a double.

public <
the enum generic type
E extends Enum<E>
>
E

Returns:

the enum instance
asEnum
(Class<E>
the enum type
enumType
)

Returns this enum value as an instance of the enum type.

public ClassInfo

Returns:

a ClassInfo representing the enum type
asEnumClass
()

Returns the type of this enum value.

public String

Returns:

the name of this enum value
asEnumConstant
()

Returns the name of this enum value.

public float

Returns:

the float value
asFloat
()

Returns this value as a float.

public int

Returns:

the int value
asInt
()

Returns this value as an int.

public long

Returns:

the long value
asLong
()

Returns this value as a long.

public AnnotationInfo

Returns:

an AnnotationInfo instance
asNestedAnnotation
()

Returns this nested annotation value as an AnnotationInfo.

public short

Returns:

the short value
asShort
()

Returns this value as a short.

public String

Returns:

the String value
asString
()

Returns this value as a String.

public Type

Returns:

the class value, as a Type
asType
()

Returns this class value as a Type.

public default boolean

Returns:

true if the kind is an array, false otherwise
isArray
()

public default boolean

Returns:

true if the kind is a boolean, false otherwise
isBoolean
()

public default boolean

Returns:

true if the kind is a byte, false otherwise
isByte
()

public default boolean

Returns:

true if the kind is a char, false otherwise
isChar
()

public default boolean

Returns:

true if the kind is a Class, false otherwise
isClass
()

public default boolean

Returns:

true if the kind is a double, false otherwise
isDouble
()

public default boolean

Returns:

true if the kind is an Enum, false otherwise
isEnum
()

public default boolean

Returns:

true if the kind is a float, false otherwise
isFloat
()

public default boolean

Returns:

true if the kind is an int, false otherwise
isInt
()

public default boolean

Returns:

true if the kind is a long, false otherwise
isLong
()

public default boolean

Returns:

true if the kind is a nested Annotation, false otherwise
isNestedAnnotation
()

public default boolean

Returns:

true if the kind is a short, false otherwise
isShort
()

public default boolean

Returns:

true if the kind is a String, false otherwise
isString
()

public AnnotationMember.Kind

Returns:

the kind of this annotation member value, never null
kind
()

Returns the kind of this annotation member value.

Field Detail

VALUEback to summary
public static final String VALUE

Name of the commonly used value() annotation member.

Method Detail

asArrayback to summary
public List<AnnotationMember> asArray()

Returns this array value as an immutable List of AnnotationMembers. Returns an empty list if the array is empty.

Returns:List<AnnotationMember>

an immutable list of AnnotationMembers

Exceptions
IllegalStateException:
if this annotation member value is not an array
asBooleanback to summary
public boolean asBoolean()

Returns this value as a boolean.

Returns:boolean

the boolean value

Exceptions
IllegalStateException:
if this annotation member value is not a boolean
asByteback to summary
public byte asByte()

Returns this value as a byte.

Returns:byte

the byte value

Exceptions
IllegalStateException:
if this annotation member value is not a byte
asCharback to summary
public char asChar()

Returns this value as a char.

Returns:char

the char value

Exceptions
IllegalStateException:
if this annotation member value is not a char
asDoubleback to summary
public double asDouble()

Returns this value as a double.

Returns:double

the double value

Exceptions
IllegalStateException:
if this annotation member value is not a double
asEnumback to summary
public <E extends Enum<E>> E asEnum(Class<E> enumType)

Returns this enum value as an instance of the enum type.

Parameters
<E>
the enum generic type
enumType:Class<E>

the enum type

Returns:E

the enum instance

Exceptions
IllegalArgumentException:
if given enumType is not an enum type
IllegalStateException:
if this annotation member value is not an enum value
asEnumClassback to summary
public ClassInfo asEnumClass()

Returns the type of this enum value.

Returns:ClassInfo

a ClassInfo representing the enum type

Exceptions
IllegalStateException:
if this annotation member value is not an enum value
asEnumConstantback to summary
public String asEnumConstant()

Returns the name of this enum value.

Returns:String

the name of this enum value

Exceptions
IllegalStateException:
if this annotation member value is not an enum value
asFloatback to summary
public float asFloat()

Returns this value as a float.

Returns:float

the float value

Exceptions
IllegalStateException:
if this annotation member value is not a float
asIntback to summary
public int asInt()

Returns this value as an int.

Returns:int

the int value

Exceptions
IllegalStateException:
if this annotation member value is not an int
asLongback to summary
public long asLong()

Returns this value as a long.

Returns:long

the long value

Exceptions
IllegalStateException:
if this annotation member value is not a long
asNestedAnnotationback to summary
public AnnotationInfo asNestedAnnotation()

Returns this nested annotation value as an AnnotationInfo.

Returns:AnnotationInfo

an AnnotationInfo instance

Exceptions
IllegalStateException:
if this annotation member value is not a nested annotation
asShortback to summary
public short asShort()

Returns this value as a short.

Returns:short

the short value

Exceptions
IllegalStateException:
if this annotation member value is not a short
asStringback to summary
public String asString()

Returns this value as a String.

Returns:String

the String value

Exceptions
IllegalStateException:
if this annotation member value is not a String
asTypeback to summary
public Type asType()

Returns this class value as a Type. It can be:

  • the void pseudo-type;
  • a primitive type;
  • a class type;
  • an array type, whose element type is a primitive type or a class type.
Returns:Type

the class value, as a Type

Exceptions
IllegalStateException:
if this annotation member value is not a class value
isArrayback to summary
public default boolean isArray()
Returns:boolean

true if the kind is an array, false otherwise

isBooleanback to summary
public default boolean isBoolean()
Returns:boolean

true if the kind is a boolean, false otherwise

isByteback to summary
public default boolean isByte()
Returns:boolean

true if the kind is a byte, false otherwise

isCharback to summary
public default boolean isChar()
Returns:boolean

true if the kind is a char, false otherwise

isClassback to summary
public default boolean isClass()
Returns:boolean

true if the kind is a Class, false otherwise

isDoubleback to summary
public default boolean isDouble()
Returns:boolean

true if the kind is a double, false otherwise

isEnumback to summary
public default boolean isEnum()
Returns:boolean

true if the kind is an Enum, false otherwise

isFloatback to summary
public default boolean isFloat()
Returns:boolean

true if the kind is a float, false otherwise

isIntback to summary
public default boolean isInt()
Returns:boolean

true if the kind is an int, false otherwise

isLongback to summary
public default boolean isLong()
Returns:boolean

true if the kind is a long, false otherwise

isNestedAnnotationback to summary
public default boolean isNestedAnnotation()
Returns:boolean

true if the kind is a nested Annotation, false otherwise

isShortback to summary
public default boolean isShort()
Returns:boolean

true if the kind is a short, false otherwise

isStringback to summary
public default boolean isString()
Returns:boolean

true if the kind is a String, false otherwise

kindback to summary
public AnnotationMember.Kind kind()

Returns the kind of this annotation member value.

Returns:AnnotationMember.Kind

the kind of this annotation member value, never null

jakarta.enterprise.lang.model back to summary

public final Enum AnnotationMember.Kind

extends Enum<AnnotationMember.Kind>
Class Inheritance

The kind of the annotation member value.

Field Summary

Modifier and TypeField and Description
public static final AnnotationMember.Kind
ARRAY

An array value.

public static final AnnotationMember.Kind
BOOLEAN

A primitive boolean value.

public static final AnnotationMember.Kind
BYTE

A primitive byte value.

public static final AnnotationMember.Kind
CHAR

A primitive char value.

public static final AnnotationMember.Kind
CLASS

A Class value.

public static final AnnotationMember.Kind
DOUBLE

A primitive double value.

public static final AnnotationMember.Kind
ENUM

An Enum value.

public static final AnnotationMember.Kind
FLOAT

A primitive float value.

public static final AnnotationMember.Kind
INT

A primitive int value.

public static final AnnotationMember.Kind
LONG

A primitive long value.

public static final AnnotationMember.Kind
public static final AnnotationMember.Kind
SHORT

A primitive short value.

public static final AnnotationMember.Kind
STRING

A String value.

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static AnnotationMember.Kind
public static AnnotationMember.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ARRAYback to summary
public static final AnnotationMember.Kind ARRAY

An array value.

BOOLEANback to summary
public static final AnnotationMember.Kind BOOLEAN

A primitive boolean value.

BYTEback to summary
public static final AnnotationMember.Kind BYTE

A primitive byte value.

CHARback to summary
public static final AnnotationMember.Kind CHAR

A primitive char value.

CLASSback to summary
public static final AnnotationMember.Kind CLASS

A Class value. Represented as Type.

DOUBLEback to summary
public static final AnnotationMember.Kind DOUBLE

A primitive double value.

ENUMback to summary
public static final AnnotationMember.Kind ENUM

An Enum value.

FLOATback to summary
public static final AnnotationMember.Kind FLOAT

A primitive float value.

INTback to summary
public static final AnnotationMember.Kind INT

A primitive int value.

LONGback to summary
public static final AnnotationMember.Kind LONG

A primitive long value.

NESTED_ANNOTATIONback to summary
public static final AnnotationMember.Kind NESTED_ANNOTATION

A nested Annotation value. Represented as AnnotationInfo.

SHORTback to summary
public static final AnnotationMember.Kind SHORT

A primitive short value.

STRINGback to summary
public static final AnnotationMember.Kind STRING

A String value.

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static AnnotationMember.Kind valueOf(String name)
valuesback to summary
public static AnnotationMember.Kind[] values()