M - The type of DataManipulator for comparisonspublic interface DataManipulator<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>> extends DataSerializable, ValueContainer<M>
DataHolder.
With a DataManipulator, specific sets of mutable data can be
represented and changed outside the live state of the DataHolder.
DataManipulators are serializable such that they can be serialized
and deserialized from persistence, and applied to DataHolders, even
with specialized Functions to use transform(Key, Function)
such that the DataManipulator is always returned.
| Modifier and Type | Method and Description |
|---|---|
I |
asImmutable()
Gets an
ImmutableDataManipulator copy of this
DataManipulator such that all backed Values are copied
into ImmutableValue counterparts. |
M |
copy()
Creates a clone copy of this
ValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance. |
default Optional<M> |
fill(DataHolder dataHolder)
Attempts to read data from the given
DataHolder and fills the
associated data onto this DataManipulator. |
Optional<M> |
fill(DataHolder dataHolder,
MergeFunction overlap)
Attempts to read data from the given
DataHolder and fills the
associated data onto this DataManipulator. |
Optional<M> |
from(DataContainer container)
Attempts to read the raw data from the provided
DataContainer. |
default M |
set(BaseValue<?>... values)
Sets the supported
BaseValues onto this DataManipulator. |
default M |
set(BaseValue<?> value)
Sets the supported
BaseValue onto this DataManipulator. |
default M |
set(Iterable<? extends BaseValue<?>> values)
Sets the supported
BaseValues onto this DataManipulator. |
<E> M |
set(Key<? extends BaseValue<E>> key,
E value)
Sets the supported
Key's value such that the value is set on
this DataManipulator without having to directly set the
Value and set(BaseValue) afterwards. |
default <E> M |
transform(Key<? extends BaseValue<E>> key,
Function<E,E> function)
Applies a transformation on the provided value if available.
|
getContentVersion, toContainerdefault Optional<M> fill(DataHolder dataHolder)
DataHolder and fills the
associated data onto this DataManipulator.
Any data that overlaps existing data from the DataHolder will
take priority and be overwritten from the pre-existing data from the
DataHolder. It is recommended that a call from
CompositeValueStore.supports(Class) is checked prior to using this
method on any DataHolder.
dataHolder - The DataHolder to extract dataDataManipulator with relevant data filled from the
given DataHolder, if compatibleOptional<M> fill(DataHolder dataHolder, MergeFunction overlap)
DataHolder and fills the
associated data onto this DataManipulator. Any data that
overlaps between this and the given DataHolder will be resolved
using the given MergeFunction.
Any data that overlaps existing data from the DataHolder will
take priority and be overwritten from the pre-existing data from the
DataHolder. It is recommended that a call from
CompositeValueStore.supports(Class) is checked prior to using this
method on any DataHolder.
dataHolder - The DataHolder to extract dataoverlap - The overlap resolver to decide which data to retainDataManipulator with relevant data filled from the
given DataHolder, if compatibleOptional<M> from(DataContainer container)
DataContainer.
This manipulator should be "reset" to a default state and apply all data
from the given DataContainer. If data is missing from the
DataContainer, Optional.empty() can be returned.container - The container of raw dataDataManipulator with relevant data filled from the
given DataContainer, if compatible<E> M set(Key<? extends BaseValue<E>> key, E value)
Key's value such that the value is set on
this DataManipulator without having to directly set the
Value and set(BaseValue) afterwards. The requirement
for this to succeed is that the Key must be checked that it is
supported via ValueContainer.supports(BaseValue) or ValueContainer.supports(Key)
otherwise an IllegalArgumentException may be thrown. For
fluency, after setting, this DataManipulator is returned.E - The type of valuekey - The key of the value to setvalue - The actual value to setdefault M set(BaseValue<?> value)
BaseValue onto this DataManipulator.
The requirement for this to succeed is that the BaseValue is
checked for support via ValueContainer.supports(BaseValue) or
ValueContainer.supports(Key) otherwise an IllegalArgumentException
may be thrown. For fluency, after setting, this DataManipulator
is returned.value - The actual value to setdefault M set(BaseValue<?>... values)
BaseValues onto this DataManipulator.
The requirement for this to succeed is that the BaseValue is
checked for support via ValueContainer.supports(BaseValue) or
ValueContainer.supports(Key) otherwise an IllegalArgumentException
may be thrown. For fluency, after setting, this DataManipulator
is returned.values - The actual values to setdefault M set(Iterable<? extends BaseValue<?>> values)
BaseValues onto this DataManipulator.
The requirement for this to succeed is that the BaseValue is
checked for support via ValueContainer.supports(BaseValue) or
ValueContainer.supports(Key) otherwise an IllegalArgumentException
may be thrown. For fluency, after setting, this DataManipulator
is returned.values - The actual values to setdefault <E> M transform(Key<? extends BaseValue<E>> key, Function<E,E> function)
CompositeValueStore.transform(Key, Function).E - The type of elementkey - The key to usefunction - The function to applyM copy()
ValueContainerValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance.copy in interface ValueContainer<M extends DataManipulator<M,I>>I asImmutable()
ImmutableDataManipulator copy of this
DataManipulator such that all backed Values are copied
into ImmutableValue counterparts. Any changes to this
DataManipulator will NOT be reflected on the returned
ImmutableDataManipulator and vice versa.DataManipulator's data copied into a
ImmutableDataManipulator