Class FieldInfo
- java.lang.Object
-
- io.github.lukehutch.fastclasspathscanner.scanner.FieldInfo
-
- All Implemented Interfaces:
Comparable<FieldInfo>
public class FieldInfo extends Object implements 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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compareTo(FieldInfo other)
Sort in order of class name then field nameboolean
equals(Object obj)
Use class name and field name for equals().List<AnnotationInfo>
getAnnotationInfo()
Get a list of annotations on this field, along with any annotation parameter values, wrapped inAnnotationInfo
objects.List<String>
getAnnotationNames()
Returns the names of unique annotations on the field.List<Class<?>>
getAnnotationTypes()
ReturnsClass<?>
references for the unique annotations on this field.String
getClassName()
Get the name of the class this field is defined within.Object
getConstFinalValue()
Returns the constant final initializer value of the field.String
getFieldName()
Returns the name of the field.int
getModifiers()
Returns the modifier bits for the field.String
getModifierStr()
Get the field modifiers as a string, e.g.String
getModifierStrs()
Deprecated.Class<?>
getType()
Returns theClass<?>
reference for the field.TypeSignature
getTypeDescriptor()
Returns the parsed type descriptor for the field, if available.String
getTypeDescriptorStr()
Returns the low-level internal type descriptor string for the field, without type parameters, e.g.TypeSignature
getTypeSignature()
Returns the parsed type signature for the field, if available.TypeSignature
getTypeSignatureOrTypeDescriptor()
Returns the parsed type signature for the field, possibly including type parameters.String
getTypeSignatureStr()
Returns the low-level internal type signature string for the method, possibly with type parameters.int
hashCode()
Use hash code of class name and field name.boolean
isFinal()
Returns true if this field is final.boolean
isPackagePrivate()
Returns true if this field is package-private.boolean
isPrivate()
Returns true if this field is private.boolean
isProtected()
Returns true if this field is protected.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.String
toString()
-
-
-
Constructor Detail
-
FieldInfo
public FieldInfo(String className, String fieldName, int modifiers, String typeDescriptorStr, String typeSignatureStr, Object constValue, List<AnnotationInfo> annotationInfo)
- Parameters:
className
- The class the field is defined within.fieldName
- The name of the field.modifiers
- The field modifiers.typeDescriptorStr
- The field type descriptor.typeSignatureStr
- The field type signature.constValue
- The static constant value the field is initialized to, if any.annotationInfo
-AnnotationInfo
for any annotations on the field.
-
-
Method Detail
-
getClassName
public String getClassName()
Get the name of the class this field is defined within.- Returns:
- The name of the class this field is defined within.
-
getFieldName
public String getFieldName()
Returns the name of the field.- Returns:
- The name of the field.
-
getModifierStrs
@Deprecated public String getModifierStrs()
Deprecated.Deprecated, use getModifierStr() instead.- Returns:
- The modifiers as a string.
-
getModifierStr
public 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.
-
isPrivate
public boolean isPrivate()
Returns true if this field is private.- Returns:
- True if the field is private.
-
isProtected
public boolean isProtected()
Returns true if this field is protected.- Returns:
- True if the field is protected.
-
isPackagePrivate
public boolean isPackagePrivate()
Returns true if this field is package-private.- Returns:
- True if the field is package-private.
-
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.
-
getTypeDescriptorStr
public String getTypeDescriptorStr()
Returns the low-level internal type descriptor string for the field, without type parameters, e.g. "Ljava/util/List;".- Returns:
- The low-level type descriptor for the field.
-
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.
-
getTypeSignatureStr
public String getTypeSignatureStr()
Returns the low-level internal type signature string for the method, possibly with type parameters.- Returns:
- The low-level internal type descriptor for the field.
-
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 parsed 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 parsed type descriptor instead.- Returns:
- The parsed type signature for the field, or if not available, the parsed type descriptor for the field.
-
getType
public Class<?> getType() throws IllegalArgumentException
Returns theClass<?>
reference for the field. Note that this calls Class.forName() on the field type, which will cause the class to be loaded, and possibly initialized. If the class is initialized, this can trigger side effects.- Returns:
- The
Class<?>
reference for the field. - Throws:
IllegalArgumentException
- if the field type could not be loaded.
-
getConstFinalValue
public Object getConstFinalValue()
Returns the constant final initializer value of the field.- Returns:
- The constant final initializer value of the field, or null if none.
-
getAnnotationNames
public List<String> getAnnotationNames()
Returns the names of unique annotations on the field.- Returns:
- The names of unique annotations on the field, or the empty list if none.
-
getAnnotationTypes
public List<Class<?>> getAnnotationTypes() throws IllegalArgumentException
ReturnsClass<?>
references for the unique annotations on this field. Note that this calls Class.forName() on the annotation types, which will cause each annotation class to be loaded.- Returns:
Class<?>
references for the unique annotations on this field.- Throws:
IllegalArgumentException
- if the annotation type could not be loaded.
-
getAnnotationInfo
public List<AnnotationInfo> getAnnotationInfo()
Get a list of annotations on this field, along with any annotation parameter values, wrapped inAnnotationInfo
objects.- Returns:
- A list of annotations on this field, along with any annotation parameter values, wrapped in
AnnotationInfo
objects, or the empty list if none.
-
equals
public boolean equals(Object obj)
Use class name and field name for equals().
-
hashCode
public int hashCode()
Use hash code of class name and field name.
-
compareTo
public int compareTo(FieldInfo other)
Sort in order of class name then field name- Specified by:
compareTo
in interfaceComparable<FieldInfo>
-
-