Class FieldAccessor

java.lang.Object
nl.jqno.equalsverifier.internal.reflection.FieldAccessor

public final class FieldAccessor extends Object
Provides reflective access to one field of an object.
  • Method Details

    • of

      public static FieldAccessor of(Field field)
      Factory method.
      Parameters:
      field - The field to access.
      Returns:
      A FieldAccessor for field.
    • getField

      public Field getField()
      Returns:
      The field itself.
    • getFieldType

      public Class<?> getFieldType()
      Returns:
      The field's type.
    • getFieldName

      public String getFieldName()
      Returns:
      The field's name.
    • fieldIsPrimitive

      public boolean fieldIsPrimitive()
      Returns:
      Whether the field is of a primitive type.
    • fieldIsFinal

      public boolean fieldIsFinal()
      Returns:
      Whether the field is marked with the final modifier.
    • fieldIsStatic

      public boolean fieldIsStatic()
      Returns:
      Whether the field is marked with the static modifier.
    • fieldIsTransient

      public boolean fieldIsTransient()
      Returns:
      Whether the field is marked with the transient modifier.
    • fieldIsEmptyOrSingleValueEnum

      public boolean fieldIsEmptyOrSingleValueEnum()
      Returns:
      Whether the field is an enum with a single value.
    • get

      public Object get(Object object)
      Tries to get the field's value.
      Parameters:
      object - The object that contains the field whose value we want to get.
      Returns:
      The field's value.
      Throws:
      ReflectionException - If the operation fails.
    • canBeModifiedReflectively

      public boolean canBeModifiedReflectively()
      Determines whether the field can be modified using reflection.
      Returns:
      Whether or not the field can be modified reflectively.