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

public final class FieldProbe extends Object
Provides read-only reflective access to one field of an object.
  • Field Details

    • field

      private final Field field
  • Constructor Details

    • FieldProbe

      private FieldProbe(Field field)
      Private constructor. Call of(Field) to instantiate.
  • Method Details

    • of

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

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

      public Object getValue(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.
    • getType

      public Class<?> getType()
      Returns the field's type.
      Returns:
      The field's type.
    • getName

      public String getName()
      Returns the field's name.
      Returns:
      The field's name.
    • getDisplayName

      public String getDisplayName()
      Returns the field's display name. This accounts for Kotlin delegates.
      Returns:
      The field's display name.
    • isPrimitive

      public boolean isPrimitive()
      Returns whether the field is primitive.
      Returns:
      Whether the field is of a primitive type.
    • isPublic

      public boolean isPublic()
      Returns whether the field is public.
      Returns:
      Whether the field has public visibility
    • isFinal

      public boolean isFinal()
      Returns whether the field is final.
      Returns:
      Whether the field is marked with the final modifier.
    • isStatic

      public boolean isStatic()
      Returns whether the field is static.
      Returns:
      Whether the field is marked with the static modifier.
    • isTransient

      public boolean isTransient()
      Returns whether the field is transient.
      Returns:
      Whether the field is marked with the transient modifier.
    • isEmptyOrSingleValueEnum

      public boolean isEmptyOrSingleValueEnum()
      Returns whether the field is a single-value enum.
      Returns:
      Whether the field is an enum with a single value.
    • canBeDefault

      public boolean canBeDefault(Configuration<?> config)
      Returns whether the field can be set to the default value for its type.
      Parameters:
      config - The configuration affects whether a given field van be default.
      Returns:
      Whether the field can be set to the default value for its type.
    • isAnnotatedNonnull

      public boolean isAnnotatedNonnull(AnnotationCache annotationCache)
      Checks whether the given field is marked with an Nonnull annotation, whether directly, or through some default annotation mechanism.
      Parameters:
      annotationCache - To retrieve annotations from.
      Returns:
      True if the field is to be treated as Nonnull.
    • canBeModifiedReflectively

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