Class FieldModifier
- java.lang.Object
-
- nl.jqno.equalsverifier.internal.reflection.FieldModifier
-
public final class FieldModifier extends Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeField(PrefabValues prefabValues, TypeTag enclosingType)
Changes the field's value to something else.void
copyTo(Object to)
Copies field's value to the corresponding field in the specified object.void
defaultField()
Tries to make the field null.void
defaultStaticField()
Tries to make the field null.static FieldModifier
of(Field field, Object object)
Factory method.void
set(Object value)
Tries to set the field to the specified value.
-
-
-
Method Detail
-
of
public static FieldModifier of(Field field, Object object)
Factory method.- Parameters:
field
- The field to modify.object
- An object that contains the field we want to modify.- Returns:
- A
FieldModifier
forfield
inobject
.
-
set
public void set(Object value)
Tries to set the field to the specified value.Includes static fields but ignores fields that can't be modified reflectively.
- Parameters:
value
- The value that the field should get.- Throws:
ReflectionException
- If the operation fails.
-
defaultField
public void defaultField()
Tries to make the field null. Ignores static fields and fields that can't be modified reflectively.- Throws:
ReflectionException
- If the operation fails.
-
defaultStaticField
public void defaultStaticField()
Tries to make the field null. Includes static fields but ignores fields that can't be modified reflectively.- Throws:
ReflectionException
- If the operation fails.
-
copyTo
public void copyTo(Object to)
Copies field's value to the corresponding field in the specified object.Ignores static fields and fields that can't be modified reflectively.
- Parameters:
to
- The object into which to copy the field.- Throws:
ReflectionException
- If the operation fails.
-
changeField
public void changeField(PrefabValues prefabValues, TypeTag enclosingType)
Changes the field's value to something else. The new value will never be null. Other than that, the precise value is undefined.Ignores static fields and fields that can't be modified reflectively.
- Parameters:
prefabValues
- If the field is of a type contained within prefabValues, the new value will be taken from it.enclosingType
- A tag for the type that contains the field. Needed to determine a generic type, if it has one..- Throws:
ReflectionException
- If the operation fails.
-
-