Class 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.
    • 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 the Class<?> 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:
        TheClass<?> 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
        Returns Class<?> 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 in AnnotationInfo 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().
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Use hash code of class name and field name.
        Overrides:
        hashCode in class Object