Package org.jboss.jandex
Class FieldInfo
java.lang.Object
org.jboss.jandex.FieldInfo
- All Implemented Interfaces:
AnnotationTarget
Represents a field.
Thread-Safety
This class is immutable and can be shared between threads without safe publication.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.jandex.AnnotationTarget
AnnotationTarget.Kind
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AnnotationInstance
annotation
(DotName name) Retrieves an annotation instance declared on this field.Returns the list of annotation instances declared on this field.final List
<AnnotationInstance> annotationsWithRepeatable
(DotName name, IndexView index) Retrieves annotation instances declared on this field, by the name of the annotation.final ClassInfo
asClass()
Casts and returns this target as aClassInfo
if it is of kindCLASS
final FieldInfo
asField()
Casts and returns this target as aFieldInfo
if it is of kindFIELD
final MethodInfo
asMethod()
Casts and returns this target as aMethodInfo
if it is of kindMETHOD
final MethodParameterInfo
Casts and returns this target as aMethodParameterInfo
if it is of kindMETHOD_PARAMETER
Casts and returns this target as aRecordComponentInfo
if it is of kindRECORD_COMPONENT
final TypeTarget
asType()
Casts and returns this target as aTypeTarget
if it is of kindTYPE
static FieldInfo
Construct a new mock Field instance.final ClassInfo
Returns the class which declared the fieldboolean
(package private) FieldInternal
final short
flags()
Returns the access fields of this field.final boolean
hasAnnotation
(DotName name) Returns whether or not the annotation instance with the given name occurs on this fieldint
hashCode()
boolean
Returns whether or not this field is declared as an element of an enum.final boolean
final AnnotationTarget.Kind
kind()
Returns the kind of object this target represents.final String
name()
Returns the local name of the field(package private) void
setAnnotations
(List<AnnotationInstance> annotations) (package private) void
setClassInfo
(ClassInfo clazz) (package private) void
setFieldInternal
(FieldInternal internal) (package private) void
toString()
Returns a string representation describing this field.final Type
type()
Returns theType
declared on this field.
-
Field Details
-
clazz
-
internal
-
-
Constructor Details
-
FieldInfo
FieldInfo() -
FieldInfo
FieldInfo(ClassInfo clazz, FieldInternal internal) -
FieldInfo
-
-
Method Details
-
create
Construct a new mock Field instance.- Parameters:
clazz
- the class declaring the fieldname
- the name of the fieldtype
- the Java field typeflags
- the field attributes- Returns:
- a mock field
-
name
Returns the local name of the field- Returns:
- the local name of the field
-
declaringClass
Returns the class which declared the field- Returns:
- the declaring class
-
type
Returns theType
declared on this field. This may be an array, a primitive, or a generic type definition.- Returns:
- the type of this field
-
kind
Description copied from interface:AnnotationTarget
Returns the kind of object this target represents.- Specified by:
kind
in interfaceAnnotationTarget
- Returns:
- the target kind.
-
annotations
Returns the list of annotation instances declared on this field. It may be empty, but never null.- Returns:
- the list of annotations on this field
-
annotation
Retrieves an annotation instance declared on this field. If an annotation by that name is not present, null will be returned.- Parameters:
name
- the name of the annotation to locate on this field- Returns:
- the annotation if found, otherwise, null
-
annotationsWithRepeatable
Retrieves annotation instances declared on this field, by the name of the annotation. If the specified annotation is repeatable (JLS 9.6), the result also contains all values from the container annotation instance.- Parameters:
name
- the name of the annotationindex
- the index used to obtain the annotation class- Returns:
- the annotation instances declared on this field, or an empty list if none
- Throws:
IllegalArgumentException
- If the index does not contain the annotation definition or if it does not represent an annotation type
-
hasAnnotation
Returns whether or not the annotation instance with the given name occurs on this field- Parameters:
name
- the name of the annotation to look for- Returns:
- true if the annotation is present, false otherwise
- See Also:
-
isEnumConstant
public boolean isEnumConstant()Returns whether or not this field is declared as an element of an enum.- Returns:
- true if the field is declared as an element of an enum, false otherwise.
- See Also:
-
flags
public final short flags()Returns the access fields of this field.Modifier
can be used on this value.- Returns:
- the access flags of this field
-
isSynthetic
public final boolean isSynthetic()- Returns:
true
if this field is a synthetic field
-
toString
Returns a string representation describing this field. It is similar although not necessarily equivalent to a Java source code expression representing this field. -
asClass
Description copied from interface:AnnotationTarget
Casts and returns this target as aClassInfo
if it is of kindCLASS
- Specified by:
asClass
in interfaceAnnotationTarget
- Returns:
- this instance cast to a class
-
asField
Description copied from interface:AnnotationTarget
Casts and returns this target as aFieldInfo
if it is of kindFIELD
- Specified by:
asField
in interfaceAnnotationTarget
- Returns:
- this instance cast to a field
-
asMethod
Description copied from interface:AnnotationTarget
Casts and returns this target as aMethodInfo
if it is of kindMETHOD
- Specified by:
asMethod
in interfaceAnnotationTarget
- Returns:
- this instance cast to a method
-
asMethodParameter
Description copied from interface:AnnotationTarget
Casts and returns this target as aMethodParameterInfo
if it is of kindMETHOD_PARAMETER
- Specified by:
asMethodParameter
in interfaceAnnotationTarget
- Returns:
- this instance cast to a method parameter
-
asType
Description copied from interface:AnnotationTarget
Casts and returns this target as aTypeTarget
if it is of kindTYPE
- Specified by:
asType
in interfaceAnnotationTarget
- Returns:
- this instance cast to a type target
-
asRecordComponent
Description copied from interface:AnnotationTarget
Casts and returns this target as aRecordComponentInfo
if it is of kindRECORD_COMPONENT
- Specified by:
asRecordComponent
in interfaceAnnotationTarget
- Returns:
- this instance cast to a record component
-
hashCode
public int hashCode() -
equals
-
setType
-
setAnnotations
-
fieldInternal
FieldInternal fieldInternal() -
setFieldInternal
-
setClassInfo
-