Package io.github.classgraph
Class FieldInfo
- java.lang.Object
-
- io.github.classgraph.FieldInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected ScanResultscanResult
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(FieldInfo other)Sort in order of class name then field namebooleanequals(java.lang.Object obj)Use class name and field name for equals().AnnotationInfoListgetAnnotationInfo()Get a list of annotations on this field, along with any annotation parameter values, wrapped inAnnotationInfoobjects.AnnotationInfogetAnnotationInfo(java.lang.String annotationName)Get a the named annotation on this field, or null if the field does not have the named annotation.ClassInfogetClassInfo()protected java.lang.StringgetClassName()Returns the name of the declaring class, so that super.getClassInfo() returns theClassInfoobject for the declaring class.java.lang.ObjectgetConstantInitializerValue()Returns the constant initializer value of a constant final field.intgetModifiers()Returns the modifier bits for the field.java.lang.StringgetModifierStr()Get the field modifiers as a string, e.g.java.lang.StringgetName()protected voidgetReferencedClassNames(java.util.Set<java.lang.String> classNames)Get the names of any classes in the type descriptor or type signature.TypeSignaturegetTypeDescriptor()Returns the parsed type descriptor for the field, if available.TypeSignaturegetTypeSignature()Returns the parsed type signature for the field, if available.TypeSignaturegetTypeSignatureOrTypeDescriptor()Returns the type signature for the field, possibly including type parameters.booleanhasAnnotation(java.lang.String annotationName)inthashCode()Use hash code of class name and field name.booleanisFinal()Returns true if this field is final.booleanisPublic()Returns true if this field is public.booleanisStatic()Returns true if this field is static.booleanisTransient()Returns true if this field is a transient field.java.lang.reflect.FieldloadClassAndGetField()Load the class this field is associated with, and get theFieldreference for this field.java.lang.StringtoString()
-
-
-
Field Detail
-
scanResult
protected transient ScanResult scanResult
-
-
Method Detail
-
getName
public java.lang.String getName()
- Returns:
- The name of the field.
-
getClassInfo
public ClassInfo getClassInfo()
- Returns:
- The
ClassInfoobject for the declaring class (i.e. the class that declares this field).
-
getModifierStr
public java.lang.String getModifierStr()
Get the field modifiers as a string, e.g. "public static final". For the modifier bits, call getModifiers().- Returns:
- The field modifiers, as a string.
-
isPublic
public boolean isPublic()
Returns true if this field is public.- Returns:
- True if the field is public.
-
isStatic
public boolean isStatic()
Returns true if this field is static.- Returns:
- True if the field is static.
-
isFinal
public boolean isFinal()
Returns true if this field is final.- Returns:
- True if the field is final.
-
isTransient
public boolean isTransient()
Returns true if this field is a transient field.- Returns:
- True if the field is transient.
-
getModifiers
public int getModifiers()
Returns the modifier bits for the field.- Returns:
- The modifier bits.
-
getTypeDescriptor
public TypeSignature getTypeDescriptor()
Returns the parsed type descriptor for the field, if available.- Returns:
- The parsed type descriptor for the field, if available, else returns null.
-
getTypeSignature
public TypeSignature getTypeSignature()
Returns the parsed type signature for the field, if available.- Returns:
- The parsed type signature for the field, if available, else returns null.
-
getTypeSignatureOrTypeDescriptor
public TypeSignature getTypeSignatureOrTypeDescriptor()
Returns the type signature for the field, possibly including type parameters. If the type signature is null, indicating that no type signature information is available for this field, returns the type descriptor instead.- Returns:
- The parsed type signature for the field, or if not available, the parsed type descriptor for the field.
-
getConstantInitializerValue
public java.lang.Object getConstantInitializerValue()
Returns the constant initializer value of a constant final field. RequiresClassGraph.enableStaticFinalFieldConstantInitializerValues()to have been called.- Returns:
- The initializer value, if this is a static final field, and has a constant initializer value, or null if none.
-
getAnnotationInfo
public AnnotationInfoList getAnnotationInfo()
Get a list of annotations on this field, along with any annotation parameter values, wrapped inAnnotationInfoobjects.- Returns:
- A list of annotations on this field, along with any annotation parameter values, wrapped in
AnnotationInfoobjects, or the empty list if none.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.String annotationName)
Get a the named annotation on this field, or null if the field does not have the named annotation.- Parameters:
annotationName- The annotation name.- Returns:
- An
AnnotationInfoobject representing the named annotation on this field, or null if the field does not have the named annotation.
-
hasAnnotation
public boolean hasAnnotation(java.lang.String annotationName)
- Parameters:
annotationName- The name of an annotation.- Returns:
- true if this field has the named annotation.
-
loadClassAndGetField
public java.lang.reflect.Field loadClassAndGetField() throws java.lang.IllegalArgumentExceptionLoad the class this field is associated with, and get theFieldreference for this field.- Returns:
- The
Fieldreference for this field. - Throws:
java.lang.IllegalArgumentException- if the field does not exist.
-
getClassName
protected java.lang.String getClassName()
Returns the name of the declaring class, so that super.getClassInfo() returns theClassInfoobject for the declaring class.- Returns:
- The class name.
-
getReferencedClassNames
protected void getReferencedClassNames(java.util.Set<java.lang.String> classNames)
Get the names of any classes in the type descriptor or type signature.
-
equals
public boolean equals(java.lang.Object obj)
Use class name and field name for equals().- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Use hash code of class name and field name.- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(FieldInfo other)
Sort in order of class name then field name- Specified by:
compareToin interfacejava.lang.Comparable<FieldInfo>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-