Class FieldInfo
java.lang.Object
io.github.classgraph.ClassMemberInfo
io.github.classgraph.FieldInfo
- All Implemented Interfaces:
HasName, Comparable<FieldInfo>
Holds metadata about fields of a class encountered during a scan. All values are taken directly out of the
classfile for the class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Class<?> The class ref, once the class is loaded.protected ScanResultThe scan result.Fields inherited from class ClassMemberInfo
annotationInfo, declaringClassName, modifiers, name, typeDescriptorStr, typeSignatureStr -
Method Summary
Modifier and TypeMethodDescriptionintSort in order of class name then field name.booleanUse class name and field name for equals().protected voidfindReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, nonapi.io.github.classgraph.utils.LogNode log) GetClassInfoobjects for any classes referenced in the type descriptor or type signature.Returns the constant initializer value of a field.Get the field modifiers as a string, e.g.Deprecated.Returns the parsed type descriptor for the field, which will not include type parameters.Returns the parsed type signature for the field, possibly including type parameters.Returns the type signature for the field, possibly including type parameters.inthashCode()Use hash code of class name and field name.booleanisEnum()Returns true if this field is an enum constant.booleanReturns true if this field is a transient field.Load the class this field is associated with, and get theFieldreference for this field.toString()Render to string.protected voidtoString(boolean useSimpleNames, StringBuilder buf) Render to string.Render to string, using only simple names for classes.Methods inherited from class ClassMemberInfo
getAnnotationInfo, getAnnotationInfo, getAnnotationInfo, getAnnotationInfoRepeatable, getAnnotationInfoRepeatable, getClassInfo, getClassName, getModifiers, getName, getTypeDescriptorStr, getTypeSignatureOrTypeDescriptorStr, getTypeSignatureStr, hasAnnotation, hasAnnotation, isFinal, isPrivate, isProtected, isPublic, isStatic, isSynthetic
-
Field Details
-
scanResult
The scan result. -
classRef
The class ref, once the class is loaded.
-
-
Method Details
-
getModifierStr
Deprecated.UsegetModifiersStr()instead.Deprecated -- usegetModifiersStr()instead.- Returns:
- The field modifiers, as a string.
-
getModifiersStr
Get the field modifiers as a string, e.g. "public static final". For the modifier bits, call getModifiers().- Specified by:
getModifiersStrin classClassMemberInfo- Returns:
- The field modifiers, as a string.
-
isTransient
public boolean isTransient()Returns true if this field is a transient field.- Returns:
- True if the field is transient.
-
isEnum
public boolean isEnum()Returns true if this field is an enum constant.- Returns:
- True if the field is an enum constant.
-
getTypeDescriptor
Returns the parsed type descriptor for the field, which will not include type parameters. If you need generic type parameters, callgetTypeSignature()instead.- Specified by:
getTypeDescriptorin classClassMemberInfo- Returns:
- The parsed type descriptor string for the field.
-
getTypeSignature
Returns the parsed type signature for the field, possibly including type parameters. If this returns null, indicating that no type signature information is available for this field, callgetTypeDescriptor()instead.- Specified by:
getTypeSignaturein classClassMemberInfo- Returns:
- The parsed type signature for the field, or null if not available.
- Throws:
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).
-
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.- Specified by:
getTypeSignatureOrTypeDescriptorin classClassMemberInfo- Returns:
- The parsed type signature for the field, or if not available, the parsed type descriptor for the field.
-
getConstantInitializerValue
Returns the constant initializer value of a field. RequiresClassGraph.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.- Returns:
- The initializer value, if this field has a constant initializer value, or null if none.
-
loadClassAndGetField
Load the class this field is associated with, and get theFieldreference for this field.- Returns:
- The
Fieldreference for this field. - Throws:
IllegalArgumentException- if the class can't be loaded or the field does not exist.
-
findReferencedClassInfo
protected void findReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, nonapi.io.github.classgraph.utils.LogNode log) GetClassInfoobjects for any classes referenced in the type descriptor or type signature.- Parameters:
classNameToClassInfo- the map from class name toClassInfo.refdClassInfo- the referenced class infolog- the log
-
equals
-
hashCode
-
compareTo
Sort in order of class name then field name.- Specified by:
compareToin interfaceComparable<FieldInfo>- Parameters:
other- the other FieldInfo object to compare to.- Returns:
- the result of comparison.
-
toString
Render to string.- Parameters:
useSimpleNames- if true, use just the simple name of each class.buf- the buf
-
toStringWithSimpleNames
Render to string, using only simple names for classes.- Returns:
- the string representation, using simple names for classes.
-
toString
-
getModifiersStr()instead.