Package jakarta.enterprise.lang.model
Interface AnnotationInfo
-
public interface AnnotationInfoAn annotation instance, typically obtained from anAnnotationTarget. Provides access to annotation members and their values.Implementations of this interface are required to define the
equalsandhashCodemethods. Implementations of this interface are encouraged to define thetoStringmethod such that it returns a text resembling the corresponding Java™ syntax.There is no guarantee that any particular annotation instance, represented by an implementation of this interface, will always be represented by the same object. That includes natural singletons such as the
jakarta.inject.Singletonannotation. Instances should always be compared usingequals.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ClassInfodeclaration()Returns the declaration of this annotation's type.booleanhasMember(String name)Returns whether this annotation has a member with givenname.default booleanhasValue()Returns whether this annotation has thevaluemember.default booleanisRepeatable()Returns whether this annotation is repeatable.AnnotationMembermember(String name)Returns the value of this annotation's member with givenname.Map<String,AnnotationMember>members()Returns all members of this annotation as a map, where the key is the member name and the value is the member value.default Stringname()Binary name of this annotation's type, as defined by The Java™ Language Specification; in other words, the annotation type name as returned byClass.getName().default AnnotationMembervalue()
-
-
-
Method Detail
-
declaration
ClassInfo declaration()
Returns the declaration of this annotation's type.- Returns:
- the declaration of this annotation's type, never
null
-
name
default String name()
Binary name of this annotation's type, as defined by The Java™ Language Specification; in other words, the annotation type name as returned byClass.getName(). Equivalent todeclaration().name().- Returns:
- binary name of this annotation's type, never
null
-
isRepeatable
default boolean isRepeatable()
Returns whether this annotation is repeatable. In other words, returns whether this annotation's type is meta-annotated@Repeatable.- Returns:
- whether this annotation is repeatable
-
hasMember
boolean hasMember(String name)
Returns whether this annotation has a member with givenname.- Parameters:
name- member name, must not benull- Returns:
trueif this annotation has a member with givenname,falseotherwise
-
member
AnnotationMember member(String name)
Returns the value of this annotation's member with givenname.- Parameters:
name- member name, must not benull- Returns:
- value of this annotation's member with given
nameornullif such member does not exist
-
hasValue
default boolean hasValue()
Returns whether this annotation has thevaluemember.- Returns:
trueif this annotation has thevaluemember,falseotherwise
-
value
default AnnotationMember value()
- Returns:
- value of this annotation's
valuemember ornullif the member does not exist
-
members
Map<String,AnnotationMember> members()
Returns all members of this annotation as a map, where the key is the member name and the value is the member value. Returns an empty map if this annotation has no members.- Returns:
- an immutable map of all members of this annotation, never
null
-
-