public class FieldInfo extends Object implements Comparable<FieldInfo>, HasName
Modifier and Type | Method and Description |
---|---|
int |
compareTo(FieldInfo other)
Sort in order of class name then field name.
|
boolean |
equals(Object obj)
Use class name and field name for equals().
|
AnnotationInfoList |
getAnnotationInfo()
Get a list of annotations on this field, along with any annotation parameter values, wrapped in
AnnotationInfo objects. |
AnnotationInfo |
getAnnotationInfo(String annotationName)
Get a the named non-
Repeatable annotation on this field, or null if the field does not have the named
annotation. |
AnnotationInfoList |
getAnnotationInfoRepeatable(String annotationName)
Get a the named
Repeatable annotation on this field, or the empty list if the field does not have the
named annotation. |
ClassInfo |
getClassInfo()
Get the
ClassInfo object for the class that declares this field. |
String |
getClassName()
Get the name of the class that declares this field.
|
Object |
getConstantInitializerValue()
Returns the constant initializer value of a field.
|
int |
getModifiers()
Returns the modifier bits for the field.
|
String |
getModifiersStr()
Get the field modifiers as a string, e.g.
|
String |
getModifierStr()
Deprecated.
Use
getModifiersStr() instead. |
String |
getName()
Get the name of the field.
|
TypeSignature |
getTypeDescriptor()
Returns the parsed type descriptor for the field, which will not include type parameters.
|
String |
getTypeDescriptorStr()
Returns the type descriptor string for the field, which will not include type parameters.
|
TypeSignature |
getTypeSignature()
Returns the parsed type signature for the field, possibly including type parameters.
|
TypeSignature |
getTypeSignatureOrTypeDescriptor()
Returns the type signature for the field, possibly including type parameters.
|
String |
getTypeSignatureOrTypeDescriptorStr()
Returns the type signature string for the field, possibly including type parameters.
|
String |
getTypeSignatureStr()
Returns the type signature string for the field, possibly including type parameters.
|
boolean |
hasAnnotation(String annotationName)
Check if the field has a given named annotation.
|
int |
hashCode()
Use hash code of class name and field name.
|
boolean |
isFinal()
Returns true if this field is final.
|
boolean |
isPublic()
Returns true if this field is public.
|
boolean |
isStatic()
Returns true if this field is static.
|
boolean |
isTransient()
Returns true if this field is a transient field.
|
Field |
loadClassAndGetField()
Load the class this field is associated with, and get the
Field reference for this field. |
String |
toString()
Render to string.
|
String |
toStringWithSimpleNames()
Render to string, using only simple
names for classes.
|
public String getName()
public ClassInfo getClassInfo()
ClassInfo
object for the class that declares this field.ClassInfo
object for the declaring class.getClassName()
@Deprecated public String getModifierStr()
getModifiersStr()
instead.getModifiersStr()
instead.public String getModifiersStr()
public boolean isPublic()
public boolean isStatic()
public boolean isFinal()
public boolean isTransient()
public int getModifiers()
public TypeSignature getTypeDescriptor()
getTypeSignature()
instead.public String getTypeDescriptorStr()
getTypeSignatureStr()
instead.public TypeSignature getTypeSignature()
getTypeDescriptor()
instead.IllegalArgumentException
- if the field type signature cannot be parsed (this should only be thrown in the case of classfile
corruption, or a compiler bug that causes an invalid type signature to be written to the
classfile).public String getTypeSignatureStr()
getTypeDescriptorStr()
instead.public TypeSignature getTypeSignatureOrTypeDescriptor()
public String getTypeSignatureOrTypeDescriptorStr()
public Object getConstantInitializerValue()
ClassGraph.enableStaticFinalFieldConstantInitializerValues()
to have been called. Will only return
non-null for fields that have constant initializers, which is usually only fields of primitive type, or
String constants. Also note that it is up to the compiler as to whether or not a constant-valued field is
assigned as a constant in the field definition itself, or whether it is assigned manually in static or
non-static class initializer blocks or the constructor -- so your mileage may vary in being able to extract
constant initializer values.public AnnotationInfoList getAnnotationInfo()
AnnotationInfo
objects.AnnotationInfo
objects, or the empty list if none.public AnnotationInfo getAnnotationInfo(String annotationName)
Repeatable
annotation on this field, or null if the field does not have the named
annotation. (Use getAnnotationInfoRepeatable(String)
for Repeatable
annotations.)annotationName
- The annotation name.AnnotationInfo
object representing the named annotation on this field, or null if the
field does not have the named annotation.public AnnotationInfoList getAnnotationInfoRepeatable(String annotationName)
Repeatable
annotation on this field, or the empty list if the field does not have the
named annotation.annotationName
- The annotation name.AnnotationInfoList
of all instances of the named annotation on this field, or the empty
list if the field does not have the named annotation.public boolean hasAnnotation(String annotationName)
annotationName
- The name of an annotation.public Field loadClassAndGetField() throws IllegalArgumentException
Field
reference for this field.Field
reference for this field.IllegalArgumentException
- if the field does not exist.public String getClassName()
getClassInfo()
public boolean equals(Object obj)
public int hashCode()
public int compareTo(FieldInfo other)
compareTo
in interface Comparable<FieldInfo>
other
- the other FieldInfo object to compare to.public String toStringWithSimpleNames()
Copyright © 2021. All rights reserved.