java.lang.Object
nl.jqno.equalsverifier.internal.reflection.FieldProbe
Provides read-only reflective access to one field of an object.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeDefault(Configuration<?> config) Returns whether the field can be set to the default value for its type.booleanDetermines whether the field can be modified using reflection.Returns the field's display name.getField()Returns the field itself.getName()Returns the field's name.Class<?> getType()Returns the field's type.Tries to get the field's value.booleanisAnnotatedNonnull(AnnotationCache annotationCache) Checks whether the given field is marked with an Nonnull annotation, whether directly, or through some default annotation mechanism.booleanReturns whether the field is a single-value enum.booleanisFinal()Returns whether the field is final.booleanReturns whether the field is primitive.booleanisPublic()Returns whether the field is public.booleanisStatic()Returns whether the field is static.booleanReturns whether the field is transient.static FieldProbeFactory method.
-
Field Details
-
field
-
-
Constructor Details
-
FieldProbe
Private constructor. Callof(Field)to instantiate.
-
-
Method Details
-
of
Factory method.- Parameters:
field- The field to access.- Returns:
- A
FieldProbeforfield.
-
getField
Returns the field itself.- Returns:
- The field itself.
-
getValue
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
Returns the field's type.- Returns:
- The field's type.
-
getName
Returns the field's name.- Returns:
- The field's name.
-
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
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
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.
-