public final class FieldInfo extends java.lang.Object implements AnnotationTarget
Thread-Safety
This class is immutable and can be shared between threads without safe publication.AnnotationTarget.Kind
Modifier and Type | Field and Description |
---|---|
private ClassInfo |
clazz |
private FieldInternal |
internal |
Constructor and Description |
---|
FieldInfo() |
FieldInfo(ClassInfo clazz,
byte[] name,
Type type,
short flags) |
FieldInfo(ClassInfo clazz,
FieldInternal internal) |
Modifier and Type | Method and Description |
---|---|
AnnotationInstance |
annotation(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.
|
ClassInfo |
asClass()
Casts and returns this target as a
ClassInfo if it is of kind CLASS |
FieldInfo |
asField()
Casts and returns this target as a
FieldInfo if it is of kind FIELD |
MethodInfo |
asMethod()
Casts and returns this target as a
MethodInfo if it is of kind METHOD |
MethodParameterInfo |
asMethodParameter()
Casts and returns this target as a
MethodParameterInfo if it is of kind METHOD_PARAMETER |
TypeTarget |
asType()
Casts and returns this target as a
TypeTarget if it is of kind TYPE |
static FieldInfo |
create(ClassInfo clazz,
java.lang.String name,
Type type,
short flags)
Construct a new mock Field instance.
|
ClassInfo |
declaringClass()
Returns the class which declared the field
|
(package private) FieldInternal |
fieldInternal() |
short |
flags()
Returns the access fields of this field.
|
boolean |
hasAnnotation(DotName name)
Returns whether or not the annotation instance with the given name occurs on this field
|
AnnotationTarget.Kind |
kind()
Returns the kind of object this target represents.
|
java.lang.String |
name()
Returns the local name of the field
|
(package private) void |
setAnnotations(java.util.List<AnnotationInstance> annotations) |
(package private) void |
setClassInfo(ClassInfo clazz) |
(package private) void |
setFieldInternal(FieldInternal internal) |
(package private) void |
setType(Type type) |
java.lang.String |
toString()
Returns a string representation describing this field.
|
Type |
type()
Returns the
Type declared on this field. |
private ClassInfo clazz
private FieldInternal internal
FieldInfo()
FieldInfo(ClassInfo clazz, FieldInternal internal)
public static FieldInfo create(ClassInfo clazz, java.lang.String name, Type type, short flags)
clazz
- the class declaring the fieldname
- the name of the fieldtype
- the Java field typeflags
- the field attributespublic final java.lang.String name()
public final ClassInfo declaringClass()
public final Type type()
Type
declared on this field. This may be an array, a primitive, or a generic
type definition.public final AnnotationTarget.Kind kind()
AnnotationTarget
kind
in interface AnnotationTarget
public java.util.List<AnnotationInstance> annotations()
public final AnnotationInstance annotation(DotName name)
name
- the name of the annotation to locate on this fieldpublic final boolean hasAnnotation(DotName name)
name
- the name of the annotation to look forannotations()
,
annotation(DotName)
public final short flags()
Modifier
can be used on this value.public java.lang.String toString()
toString
in class java.lang.Object
public final ClassInfo asClass()
AnnotationTarget
ClassInfo
if it is of kind CLASS
asClass
in interface AnnotationTarget
public final FieldInfo asField()
AnnotationTarget
FieldInfo
if it is of kind FIELD
asField
in interface AnnotationTarget
public final MethodInfo asMethod()
AnnotationTarget
MethodInfo
if it is of kind METHOD
asMethod
in interface AnnotationTarget
public final MethodParameterInfo asMethodParameter()
AnnotationTarget
MethodParameterInfo
if it is of kind METHOD_PARAMETER
asMethodParameter
in interface AnnotationTarget
public final TypeTarget asType()
AnnotationTarget
TypeTarget
if it is of kind TYPE
asType
in interface AnnotationTarget
void setType(Type type)
void setAnnotations(java.util.List<AnnotationInstance> annotations)
FieldInternal fieldInternal()
void setFieldInternal(FieldInternal internal)
void setClassInfo(ClassInfo clazz)