java.lang.Object
org.litebridgedb.tracking.ChangedField
- Direct Known Subclasses:
ChangedCollectionField,ChangedMapField
A field which has undergone a change.
This is a sealed class that can be extended by specific implementations to handle particular types of field changes.
The class stores the name of the changed field and its value, and provides utilities for accessing and comparing these fields.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChangedField(String name, @Nullable Object value) Construct a new instance ofChangedField, representing a change in a specific field. -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends ChangedField>
Optional<T> Attempts to cast thisChangedFieldinstance to a specific subtype.booleaninthashCode()name()Retrieve the name of the field that has changed.toString()@Nullable Objectvalue()Retrieve the current value of the field that has changed.
-
Field Details
-
name
-
value
-
-
Constructor Details
-
ChangedField
Construct a new instance ofChangedField, representing a change in a specific field.- Parameters:
name- the name of the field that has changed; must not be nullvalue- the current value of the field that has changed; may be null
-
-
Method Details
-
name
Retrieve the name of the field that has changed.- Returns:
- the name of the changed field
-
value
Retrieve the current value of the field that has changed.- Returns:
- the current value of the changed field, which may be
null
-
cast
Attempts to cast thisChangedFieldinstance to a specific subtype. This provides a convenient type-safe way to cast the field to a specific subtype if it known beforehand.If the cast is possible, the corresponding subtype instance is returned wrapped in an
Optional. If the cast fails, an emptyOptionalis returned.- Type Parameters:
T- the type of the desired subtype ofChangedField- Parameters:
changedFieldType- theClassobject representing the desired subtype- Returns:
- an
Optionalcontaining the casted instance if the cast is successful, or an emptyOptionalif the cast fails
-
equals
-
hashCode
public int hashCode() -
toString
-