Top Description Fields Constructors Methods
io.github.classgraph

public Class FieldInfo

extends ClassMemberInfo
implements Comparable<FieldInfo>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.lang.annotation.Repeatable, java.lang.reflect.Field, .Modifier, java.util.List, .Map, .Set, io.github.classgraph.ClassInfo.RelType, .Classfile.TypeAnnotationDecorator, nonapi.io.github.classgraph.types.ParseException, .TypeUtils, .TypeUtils.ModifierType, nonapi.io.github.classgraph.utils.LogNode

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

Modifier and TypeField and Description
private ObjectTypedValueWrapper
constantInitializerValue

The constant initializer value for the field, if any.

private transient List<Classfile.TypeAnnotationDecorator>
typeAnnotationDecorators

The type annotation decorators for the TypeSignature instance of this field.

private transient TypeSignature
typeDescriptor

The parsed type descriptor.

private transient TypeSignature
typeSignature

The parsed type signature.

Inherited from io.github.classgraph.ClassMemberInfo:
annotationInfodeclaringClassNamemodifiersnametypeDescriptorStrtypeSignatureStr

Constructor Summary

AccessConstructor and Description
pack-priv
FieldInfo()

Default constructor for deserialization.

pack-priv
FieldInfo(final String
The class the field is defined within.
definingClassName
,
final String
The name of the field.
fieldName
,
final int
The field modifiers.
modifiers
,
final String
The field type descriptor.
typeDescriptorStr
,
final String
The field type signature.
typeSignatureStr
,
final Object
The static constant value the field is initialized to, if any.
constantInitializerValue
,
final AnnotationInfoList
AnnotationInfo for any annotations on the field.
annotationInfo
,
final List<Classfile.TypeAnnotationDecorator> typeAnnotationDecorators)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the result of comparison.
compareTo
(final FieldInfo
the other FieldInfo object to compare to.
other
)

Implements java.lang.Comparable.compareTo.

Sort in order of class name then field name.

public boolean

Returns:

true if equal
equals
(final Object
the object to compare to
obj
)

Overrides java.lang.Object.equals.

Use class name and field name for equals().

protected void
findReferencedClassInfo(final Map<String, ClassInfo>
the map from class name to ClassInfo.
classNameToClassInfo
,
final Set<ClassInfo>
the referenced class info
refdClassInfo
,
final LogNode
the log
log
)

Overrides io.github.classgraph.ScanResultObject.findReferencedClassInfo.

Get ClassInfo objects for any classes referenced in the type descriptor or type signature.

public Object

Returns:

The initializer value, if this field has a constant initializer value, or null if none.
getConstantInitializerValue
()

Returns the constant initializer value of a field.

public String

Returns:

The field modifiers, as a string.
getModifiersStr
()

Implements abstract io.github.classgraph.ClassMemberInfo.getModifiersStr.

Get the field modifiers as a string, e.g. "public static final".

public String

Returns:

The field modifiers, as a string.
getModifierStr
()
Deprecated Use getModifiersStr() instead.

Deprecated -- use getModifiersStr() instead.

public TypeSignature

Returns:

The parsed type descriptor string for the field.
getTypeDescriptor
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeDescriptor.

Returns the parsed type descriptor for the field, which will not include type parameters.

public TypeSignature

Returns:

The parsed type signature for the field, or null if not available.
getTypeSignature
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignature.

Returns the parsed type signature for the field, possibly including type parameters.

public TypeSignature

Returns:

The parsed type signature for the field, or if not available, the parsed type descriptor for the field.
getTypeSignatureOrTypeDescriptor
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignatureOrTypeDescriptor.

Returns the type signature for the field, possibly including type parameters.

pack-priv void
handleRepeatableAnnotations(final Set<String>
the names of all repeatable annotations
allRepeatableAnnotationNames
)

Handle Repeatable annotations.

public int

Returns:

the hashcode
hashCode
()

Overrides java.lang.Object.hashCode.

Use hash code of class name and field name.

public boolean

Returns:

True if the field is an enum constant.
isEnum
()

Returns true if this field is an enum constant.

public boolean

Returns:

True if the field is transient.
isTransient
()

Returns true if this field is a transient field.

public Field

Returns:

The Field reference for this field.
loadClassAndGetField
()

Load the class this field is associated with, and get the Field reference for this field.

pack-priv void
setScanResult(final ScanResult
the scan result
scanResult
)

Overrides io.github.classgraph.ScanResultObject.setScanResult.

Set ScanResult backreferences in info objects after scan has completed.

pack-priv void
toString(final boolean includeModifiers, final boolean useSimpleNames, final StringBuilder buf)

protected void
toString(final boolean
if true, use just the simple name of each class.
useSimpleNames
,
final StringBuilder
the buf
buf
)

Implements abstract io.github.classgraph.ScanResultObject.toString.

Render to string.

Inherited from io.github.classgraph.ClassMemberInfo:
getAnnotationInfogetAnnotationInfogetAnnotationInfogetAnnotationInfoRepeatablegetAnnotationInfoRepeatablegetClassInfogetClassNamegetModifiersgetNamegetTypeDescriptorStrgetTypeSignatureOrTypeDescriptorStrgetTypeSignatureStrhasAnnotationhasAnnotationisFinalisPrivateisProtectedisPublicisStaticisSynthetic

Field Detail

constantInitializerValueback to summary
private ObjectTypedValueWrapper constantInitializerValue

The constant initializer value for the field, if any.

typeAnnotationDecoratorsback to summary
private transient List<Classfile.TypeAnnotationDecorator> typeAnnotationDecorators

The type annotation decorators for the TypeSignature instance of this field.

typeDescriptorback to summary
private transient TypeSignature typeDescriptor

The parsed type descriptor.

typeSignatureback to summary
private transient TypeSignature typeSignature

The parsed type signature.

Constructor Detail

FieldInfoback to summary
pack-priv FieldInfo()

Default constructor for deserialization.

FieldInfoback to summary
pack-priv FieldInfo(final String definingClassName, final String fieldName, final int modifiers, final String typeDescriptorStr, final String typeSignatureStr, final Object constantInitializerValue, final AnnotationInfoList annotationInfo, final List<Classfile.TypeAnnotationDecorator> typeAnnotationDecorators)

Constructor.

Parameters
definingClassName:String

The class the field is defined within.

fieldName:String

The name of the field.

modifiers:int

The field modifiers.

typeDescriptorStr:String

The field type descriptor.

typeSignatureStr:String

The field type signature.

constantInitializerValue:Object

The static constant value the field is initialized to, if any.

annotationInfo:AnnotationInfoList

AnnotationInfo for any annotations on the field.

Method Detail

compareToback to summary
public int compareTo(final FieldInfo other)

Implements java.lang.Comparable.compareTo.

Sort in order of class name then field name.

Parameters
other:FieldInfo

the other FieldInfo object to compare to.

Returns:int

the result of comparison.

Annotations
@Override
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Use class name and field name for equals().

Parameters
obj:Object

the object to compare to

Returns:boolean

true if equal

Annotations
@Override
findReferencedClassInfoback to summary
protected void findReferencedClassInfo(final Map<String, ClassInfo> classNameToClassInfo, final Set<ClassInfo> refdClassInfo, final LogNode log)

Overrides io.github.classgraph.ScanResultObject.findReferencedClassInfo.

Get ClassInfo objects for any classes referenced in the type descriptor or type signature.

Parameters
classNameToClassInfo:Map<String, ClassInfo>

the map from class name to ClassInfo.

refdClassInfo:Set<ClassInfo>

the referenced class info

log:LogNode

Doc from io.github.classgraph.ScanResultObject.findReferencedClassInfo.

the log

Annotations
@Override
getConstantInitializerValueback to summary
public Object getConstantInitializerValue()

Returns the constant initializer value of a field. Requires 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.

Returns:Object

The initializer value, if this field has a constant initializer value, or null if none.

getModifiersStrback to summary
public String getModifiersStr()

Implements abstract io.github.classgraph.ClassMemberInfo.getModifiersStr.

Get the field modifiers as a string, e.g. "public static final". For the modifier bits, call getModifiers().

Returns:String

The field modifiers, as a string.

Annotations
@Override
getModifierStrback to summary
public String getModifierStr()

Deprecated

Use getModifiersStr() instead.

Deprecated -- use getModifiersStr() instead.

Returns:String

The field modifiers, as a string.

Annotations
@Deprecated
getTypeDescriptorback to summary
public TypeSignature getTypeDescriptor()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeDescriptor.

Returns the parsed type descriptor for the field, which will not include type parameters. If you need generic type parameters, call getTypeSignature() instead.

Returns:TypeSignature

The parsed type descriptor string for the field.

Annotations
@Override
getTypeSignatureback to summary
public TypeSignature getTypeSignature()

Implements abstract io.github.classgraph.ClassMemberInfo.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, call getTypeDescriptor() instead.

Returns:TypeSignature

The parsed type signature for the field, or null if not available.

Annotations
@Override
Exceptions
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).
getTypeSignatureOrTypeDescriptorback to summary
public TypeSignature getTypeSignatureOrTypeDescriptor()

Implements abstract io.github.classgraph.ClassMemberInfo.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:TypeSignature

The parsed type signature for the field, or if not available, the parsed type descriptor for the field.

Annotations
@Override
handleRepeatableAnnotationsback to summary
pack-priv void handleRepeatableAnnotations(final Set<String> allRepeatableAnnotationNames)

Handle Repeatable annotations.

Parameters
allRepeatableAnnotationNames:Set<String>

the names of all repeatable annotations

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Use hash code of class name and field name.

Returns:int

the hashcode

Annotations
@Override
isEnumback to summary
public boolean isEnum()

Returns true if this field is an enum constant.

Returns:boolean

True if the field is an enum constant.

isTransientback to summary
public boolean isTransient()

Returns true if this field is a transient field.

Returns:boolean

True if the field is transient.

loadClassAndGetFieldback to summary
public Field loadClassAndGetField() throws IllegalArgumentException

Load the class this field is associated with, and get the Field reference for this field.

Returns:Field

The Field reference for this field.

Exceptions
IllegalArgumentException:
if the class can't be loaded or the field does not exist.
setScanResultback to summary
pack-priv void setScanResult(final ScanResult scanResult)

Overrides io.github.classgraph.ScanResultObject.setScanResult.

Doc from io.github.classgraph.ScanResultObject.setScanResult.

Set ScanResult backreferences in info objects after scan has completed.

Parameters
scanResult:ScanResult

the scan result

Annotations
@Override
toStringback to summary
pack-priv void toString(final boolean includeModifiers, final boolean useSimpleNames, final StringBuilder buf)
toStringback to summary
protected void toString(final boolean useSimpleNames, final StringBuilder buf)

Implements abstract io.github.classgraph.ScanResultObject.toString.

Doc from io.github.classgraph.ScanResultObject.toString.

Render to string.

Parameters
useSimpleNames:boolean

if true, use just the simple name of each class.

buf:StringBuilder

the buf

Annotations
@Override