Interface DataManipulator.Mutable
-
- All Superinterfaces:
CopyableValueContainer
,DataManipulator
,ValueContainer
- Enclosing interface:
- DataManipulator
public static interface DataManipulator.Mutable extends DataManipulator
Represents a changelist of data that can be applied to aDataHolder
. With aDataManipulator.Mutable
, specific sets of mutable data can be represented and changed outside the live state of theDataHolder
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DataManipulator.Mutable.Factory
A factory to create newDataManipulator.Mutable
manipulators.-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default DataManipulator.Mutable
asMutable()
Gets aDataManipulator.Mutable
copy of thisDataManipulator
such that all backedValue
s are copied into theirValue.Mutable
counterparts.DataManipulator.Mutable
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, java.lang.Iterable<Key<?>> keys)
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
copyFrom(ValueContainer valueContainer, java.util.function.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
.DataManipulator.Mutable
copyFrom(ValueContainer valueContainer, MergeFunction overlap)
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.DataManipulator.Mutable
copyFrom(ValueContainer valueContainer, MergeFunction overlap, java.lang.Iterable<Key<?>> keys)
Attempts to read data from the givenValueContainer
and fills the associated data onto thisDataManipulator.Mutable
.DataManipulator.Mutable
copyFrom(ValueContainer valueContainer, MergeFunction overlap, java.util.function.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
.DataManipulator.Mutable
remove(Key<?> key)
default DataManipulator.Mutable
set(java.lang.Iterable<? extends Value<?>> values)
Sets the supportedValue
s onto thisDataManipulator.Mutable
.default <E,V extends Value<E>>
DataManipulator.Mutableset(java.util.function.Supplier<Key<V>> key, E value)
default <E,V extends Value<E>>
DataManipulator.Mutableset(java.util.function.Supplier<Key<V>> key, java.util.function.Supplier<E> value)
<E> DataManipulator.Mutable
set(Key<? extends Value<E>> key, E value)
Sets 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
set(Value<?> value)
Sets the supportedValue
onto thisDataManipulator.Mutable
.default DataManipulator.Mutable
set(Value<?>... values)
Sets the supportedValue
s onto thisDataManipulator.Mutable
.default <E> DataManipulator.Mutable
transform(Key<? extends Value<E>> key, java.util.function.Function<E,E> function)
Applies a transformation on the provided value if available.-
Methods inherited from interface org.spongepowered.api.data.DataManipulator
asImmutable, asMutableCopy
-
-
-
-
Method Detail
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, java.util.function.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, java.util.function.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
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, java.lang.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 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, java.lang.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
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer)
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
DataManipulator.Mutable copyFrom(ValueContainer valueContainer, MergeFunction overlap)
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
<E> DataManipulator.Mutable set(Key<? extends Value<E>> key, E value)
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
default <E,V extends Value<E>> DataManipulator.Mutable set(java.util.function.Supplier<Key<V>> key, E value)
-
set
default <E,V extends Value<E>> DataManipulator.Mutable set(java.util.function.Supplier<Key<V>> key, java.util.function.Supplier<E> value)
-
set
default DataManipulator.Mutable set(Value<?> value)
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
default DataManipulator.Mutable set(Value<?>... values)
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
default DataManipulator.Mutable set(java.lang.Iterable<? extends Value<?>> values)
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
default <E> DataManipulator.Mutable transform(Key<? extends Value<E>> key, java.util.function.Function<E,E> function)
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
DataManipulator.Mutable remove(Key<?> key)
-
asMutable
default DataManipulator.Mutable 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
-
-