Package org.jboss.jandex
Class FieldInfo
- java.lang.Object
-
- org.jboss.jandex.FieldInfo
-
- All Implemented Interfaces:
AnnotationTarget
public final class FieldInfo extends java.lang.Object implements 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 Modifier and Type Field Description private ClassInfoclazzprivate FieldInternalinternal
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationInstanceannotation(DotName name)Retrieves an annotation instance declared on this field.java.util.List<AnnotationInstance>annotations()Returns the list of annotation instances declared on this field.java.util.List<AnnotationInstance>annotationsWithRepeatable(DotName name, IndexView index)Retrieves annotation instances declared on this field, by the name of the annotation.ClassInfoasClass()Casts and returns this target as aClassInfoif it is of kindCLASSFieldInfoasField()Casts and returns this target as aFieldInfoif it is of kindFIELDMethodInfoasMethod()Casts and returns this target as aMethodInfoif it is of kindMETHODMethodParameterInfoasMethodParameter()Casts and returns this target as aMethodParameterInfoif it is of kindMETHOD_PARAMETERRecordComponentInfoasRecordComponent()Casts and returns this target as aRecordComponentInfoif it is of kindRECORD_COMPONENTTypeTargetasType()Casts and returns this target as aTypeTargetif it is of kindTYPEstatic FieldInfocreate(ClassInfo clazz, java.lang.String name, Type type, short flags)Construct a new mock Field instance.ClassInfodeclaringClass()Returns the class which declared the fieldbooleanequals(java.lang.Object o)(package private) FieldInternalfieldInternal()shortflags()Returns the access fields of this field.booleanhasAnnotation(DotName name)Returns whether or not the annotation instance with the given name occurs on this fieldinthashCode()booleanisEnumConstant()Returns whether or not this field is declared as an element of an enum.booleanisSynthetic()AnnotationTarget.Kindkind()Returns the kind of object this target represents.java.lang.Stringname()Returns the local name of the field(package private) voidsetAnnotations(java.util.List<AnnotationInstance> annotations)(package private) voidsetClassInfo(ClassInfo clazz)(package private) voidsetFieldInternal(FieldInternal internal)(package private) voidsetType(Type type)java.lang.StringtoString()Returns a string representation describing this field.Typetype()Returns theTypedeclared on this field.
-
-
-
Field Detail
-
clazz
private ClassInfo clazz
-
internal
private FieldInternal internal
-
-
Constructor Detail
-
FieldInfo
FieldInfo()
-
FieldInfo
FieldInfo(ClassInfo clazz, FieldInternal internal)
-
-
Method Detail
-
create
public static FieldInfo create(ClassInfo clazz, java.lang.String name, Type type, short flags)
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
public final java.lang.String name()
Returns the local name of the field- Returns:
- the local name of the field
-
declaringClass
public final ClassInfo declaringClass()
Returns the class which declared the field- Returns:
- the declaring class
-
type
public final Type type()
Returns theTypedeclared on this field. This may be an array, a primitive, or a generic type definition.- Returns:
- the type of this field
-
kind
public final AnnotationTarget.Kind kind()
Description copied from interface:AnnotationTargetReturns the kind of object this target represents.- Specified by:
kindin interfaceAnnotationTarget- Returns:
- the target kind.
-
annotations
public java.util.List<AnnotationInstance> 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
public final AnnotationInstance annotation(DotName name)
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
public final java.util.List<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)
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:
java.lang.IllegalArgumentException- If the index does not contain the annotation definition or if it does not represent an annotation type
-
hasAnnotation
public final boolean hasAnnotation(DotName name)
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:
annotations(),annotation(DotName)
-
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:
Field.isEnumConstant()
-
flags
public final short flags()
Returns the access fields of this field.Modifiercan be used on this value.- Returns:
- the access flags of this field
-
isSynthetic
public final boolean isSynthetic()
- Returns:
trueif this field is a synthetic field
-
toString
public java.lang.String toString()
Returns a string representation describing this field. It is similar although not necessarily equivalent to a Java source code expression representing this field.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation for this field
-
asClass
public final ClassInfo asClass()
Description copied from interface:AnnotationTargetCasts and returns this target as aClassInfoif it is of kindCLASS- Specified by:
asClassin interfaceAnnotationTarget- Returns:
- this instance cast to a class
-
asField
public final FieldInfo asField()
Description copied from interface:AnnotationTargetCasts and returns this target as aFieldInfoif it is of kindFIELD- Specified by:
asFieldin interfaceAnnotationTarget- Returns:
- this instance cast to a field
-
asMethod
public final MethodInfo asMethod()
Description copied from interface:AnnotationTargetCasts and returns this target as aMethodInfoif it is of kindMETHOD- Specified by:
asMethodin interfaceAnnotationTarget- Returns:
- this instance cast to a method
-
asMethodParameter
public final MethodParameterInfo asMethodParameter()
Description copied from interface:AnnotationTargetCasts and returns this target as aMethodParameterInfoif it is of kindMETHOD_PARAMETER- Specified by:
asMethodParameterin interfaceAnnotationTarget- Returns:
- this instance cast to a method parameter
-
asType
public final TypeTarget asType()
Description copied from interface:AnnotationTargetCasts and returns this target as aTypeTargetif it is of kindTYPE- Specified by:
asTypein interfaceAnnotationTarget- Returns:
- this instance cast to a type target
-
asRecordComponent
public RecordComponentInfo asRecordComponent()
Description copied from interface:AnnotationTargetCasts and returns this target as aRecordComponentInfoif it is of kindRECORD_COMPONENT- Specified by:
asRecordComponentin interfaceAnnotationTarget- Returns:
- this instance cast to a record component
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
setType
void setType(Type type)
-
setAnnotations
void setAnnotations(java.util.List<AnnotationInstance> annotations)
-
fieldInternal
FieldInternal fieldInternal()
-
setFieldInternal
void setFieldInternal(FieldInternal internal)
-
setClassInfo
void setClassInfo(ClassInfo clazz)
-
-