Interface DataManipulator.Mutable
- All Superinterfaces:
CopyableValueContainer
,DataManipulator
,ValueContainer
- Enclosing interface:
- DataManipulator
DataHolder
.
With a DataManipulator.Mutable
, specific sets of mutable data can be
represented and changed outside the live state of the DataHolder
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A factory to create newDataManipulator.Mutable
manipulators.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable
-
Method Summary
Modifier and TypeMethodDescriptiondefault DataManipulator.Mutable
Gets aDataManipulator.Mutable
copy of thisDataManipulator
such that all backedValue
s are copied into theirValue.Mutable
counterparts.copy()
Creates a clone copy of thisCopyableValueContainer
as a newCopyableValueContainer
such that all theValue
s are safely duplicated to the new instance.default DataManipulator.Mutable
copyFrom
(ValueContainer valueContainer) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
copyFrom
(ValueContainer valueContainer, Iterable<Key<?>> keys) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
copyFrom
(ValueContainer valueContainer, Predicate<Key<?>> predicate) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
copyFrom
(ValueContainer valueContainer, Key<?> first, Key<?>... more) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.copyFrom
(ValueContainer valueContainer, MergeFunction overlap) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.copyFrom
(ValueContainer valueContainer, MergeFunction overlap, Iterable<Key<?>> keys) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.copyFrom
(ValueContainer valueContainer, MergeFunction overlap, Predicate<Key<?>> predicate) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
copyFrom
(ValueContainer valueContainer, MergeFunction overlap, Key<?> first, Key<?>... more) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
Sets the supportedValue
s onto thisDataManipulator.Mutable
.default <E,
V extends Value<E>>
DataManipulator.Mutabledefault <E,
V extends Value<E>>
DataManipulator.MutableSets the supportedKey
's value such that the value is set on thisDataManipulator.Mutable
without having to directly set theValue.Mutable
andset(Value)
afterwards.default DataManipulator.Mutable
Sets the supportedValue
onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
Sets the supportedValue
s onto thisDataManipulator.Mutable
.default <E> DataManipulator.Mutable
Applies a transformation on the provided value if available.Methods inherited from interface org.spongepowered.api.data.DataManipulator
asImmutable, asMutableCopy
-
Method Details
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, Predicate<Key<?>> predicate) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. OnlyKey
s that match the predicate will be copied.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data frompredicate
- The predicate to filter which keys can be copied- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
DataManipulator.Mutable copyFrom(ValueContainer valueContainer, MergeFunction overlap, Predicate<Key<?>> predicate) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. OnlyKey
s that match the predicate will be copied.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data fromoverlap
- The overlap resolver to decide which value to retainpredicate
- The predicate to filter which keys can be copied- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, Key<?> first, Key<?>... more) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. Only the values of the providedKey
s will be copied if present.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data fromfirst
- The first key to copymore
- The additional keys to copy- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, MergeFunction overlap, Key<?> first, Key<?>... more) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. Only the values of the providedKey
s will be copied if present. Any data that overlaps between this and the givenDataHolder
will be resolved using the givenMergeFunction
.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data fromoverlap
- The overlap resolver to decide which value to retainfirst
- The first keymore
- The keys to copy- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. Only the values of the providedKey
s will be copied if present.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data fromkeys
- The keys to copy- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
DataManipulator.Mutable copyFrom(ValueContainer valueContainer, MergeFunction overlap, Iterable<Key<?>> keys) Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. Only the values of the providedKey
s will be copied if present. Any data that overlaps between this and the givenDataHolder
will be resolved using the givenMergeFunction
.Any data that overlaps existing data from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to copy data fromoverlap
- The overlap resolver to decide which value to retainkeys
- The keys to copy- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenValueContainer
-
copyFrom
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.Any values that overlaps existing values from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to extract data from- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenDataHolder
-
copyFrom
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
. Any data that overlaps between this and the givenDataHolder
will be resolved using the givenMergeFunction
.Any values that overlaps existing values from the
ValueContainer
will take priority and be overwritten from the pre-existing data from theValueContainer
.- Parameters:
valueContainer
- TheValueContainer
to extract data fromoverlap
- The overlap resolver- Returns:
- This
DataManipulator.Mutable
with relevant data filled from the givenDataHolder
-
set
Sets the supportedKey
's value such that the value is set on thisDataManipulator.Mutable
without having to directly set theValue.Mutable
andset(Value)
afterwards. The requirement for this to succeed is that theKey
must be checked that it is supported viaValueContainer.supports(Value)
orValueContainer.supports(Key)
otherwise anIllegalArgumentException
may be thrown. For fluency, after setting, thisDataManipulator.Mutable
is returned.- Type Parameters:
E
- The type of value- Parameters:
key
- The key of the value to setvalue
- The actual value to set- Returns:
- This manipulator, for chaining
-
set
-
set
default <E,V extends Value<E>> DataManipulator.Mutable set(Supplier<Key<V>> key, Supplier<E> value) -
set
Sets the supportedValue
onto thisDataManipulator.Mutable
. The requirement for this to succeed is that theValue
is checked for support viaValueContainer.supports(Value)
orValueContainer.supports(Key)
otherwise anIllegalArgumentException
may be thrown. For fluency, after setting, thisDataManipulator.Mutable
is returned.- Parameters:
value
- The actual value to set- Returns:
- This manipulator, for chaining
-
set
Sets the supportedValue
s onto thisDataManipulator.Mutable
. The requirement for this to succeed is that theValue
is checked for support viaValueContainer.supports(Value)
orValueContainer.supports(Key)
otherwise anIllegalArgumentException
may be thrown. For fluency, after setting, thisDataManipulator.Mutable
is returned.- Parameters:
values
- The actual values to set- Returns:
- This manipulator, for chaining
-
set
Sets the supportedValue
s onto thisDataManipulator.Mutable
. The requirement for this to succeed is that theValue
is checked for support viaValueContainer.supports(Value)
orValueContainer.supports(Key)
otherwise anIllegalArgumentException
may be thrown. For fluency, after setting, thisDataManipulator.Mutable
is returned.- Parameters:
values
- The actual values to set- Returns:
- This manipulator, for chaining
-
transform
Applies a transformation on the provided value if available. This is the same asDataHolder.Mutable.transform(Key, Function)
.- Type Parameters:
E
- The type of element- Parameters:
key
- The key to usefunction
- The function to apply- Returns:
- This manipulator, for chaining
-
remove
-
asMutable
Description copied from interface:DataManipulator
Gets aDataManipulator.Mutable
copy of thisDataManipulator
such that all backedValue
s are copied into theirValue.Mutable
counterparts. Any changes to thisDataManipulator
will NOT be reflected on the returnedDataManipulator.Mutable
and vice versa.The cases where this
DataManipulator
is already aDataManipulator.Mutable
, the same manipulator object is returned.- Specified by:
asMutable
in interfaceDataManipulator
- Returns:
- This
DataManipulator
's data copied into aDataManipulator.Mutable
-
copy
DataManipulator.Mutable copy()Description copied from interface:CopyableValueContainer
Creates a clone copy of thisCopyableValueContainer
as a newCopyableValueContainer
such that all theValue
s are safely duplicated to the new instance. It is not guaranteed that the returning container is of the same type as this container.- Specified by:
copy
in interfaceCopyableValueContainer
- Specified by:
copy
in interfaceDataManipulator
- Returns:
- The new copy
-