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 interfaceDataManipulator.Mutable.FactoryA factory to create newDataManipulator.Mutablemanipulators.-
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.MutableasMutable()Gets aDataManipulator.Mutablecopy of thisDataManipulatorsuch that all backedValues are copied into theirValue.Mutablecounterparts.DataManipulator.Mutablecopy()Creates a clone copy of thisCopyableValueContaineras a newCopyableValueContainersuch that all theValues are safely duplicated to the new instance.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer, java.lang.Iterable<Key<?>> keys)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer, java.util.function.Predicate<Key<?>> predicate)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer, Key<?> first, Key<?>... more)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.DataManipulator.MutablecopyFrom(ValueContainer valueContainer, MergeFunction overlap)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.DataManipulator.MutablecopyFrom(ValueContainer valueContainer, MergeFunction overlap, java.lang.Iterable<Key<?>> keys)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.DataManipulator.MutablecopyFrom(ValueContainer valueContainer, MergeFunction overlap, java.util.function.Predicate<Key<?>> predicate)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer, MergeFunction overlap, Key<?> first, Key<?>... more)Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.DataManipulator.Mutableremove(Key<?> key)default DataManipulator.Mutableset(java.lang.Iterable<? extends Value<?>> values)Sets the supportedValues 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.Mutableset(Key<? extends Value<E>> key, E value)Sets the supportedKey's value such that the value is set on thisDataManipulator.Mutablewithout having to directly set theValue.Mutableandset(Value)afterwards.default DataManipulator.Mutableset(Value<?> value)Sets the supportedValueonto thisDataManipulator.Mutable.default DataManipulator.Mutableset(Value<?>... values)Sets the supportedValues onto thisDataManipulator.Mutable.default <E> DataManipulator.Mutabletransform(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 givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. OnlyKeys that match the predicate will be copied.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data frompredicate- The predicate to filter which keys can be copied- Returns:
- This
DataManipulator.Mutablewith 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 givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. OnlyKeys that match the predicate will be copied.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data fromoverlap- The overlap resolver to decide which value to retainpredicate- The predicate to filter which keys can be copied- Returns:
- This
DataManipulator.Mutablewith relevant data filled from the givenValueContainer
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, Key<?> first, Key<?>... more)
Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. Only the values of the providedKeys will be copied if present.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data fromfirst- The first key to copymore- The additional keys to copy- Returns:
- This
DataManipulator.Mutablewith 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 givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. Only the values of the providedKeys will be copied if present. Any data that overlaps between this and the givenDataHolderwill be resolved using the givenMergeFunction.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data fromoverlap- The overlap resolver to decide which value to retainfirst- The first keymore- The keys to copy- Returns:
- This
DataManipulator.Mutablewith relevant data filled from the givenValueContainer
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer, java.lang.Iterable<Key<?>> keys)
Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. Only the values of the providedKeys will be copied if present.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data fromkeys- The keys to copy- Returns:
- This
DataManipulator.Mutablewith 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 givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. Only the values of the providedKeys will be copied if present. Any data that overlaps between this and the givenDataHolderwill be resolved using the givenMergeFunction.Any data that overlaps existing data from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto copy data fromoverlap- The overlap resolver to decide which value to retainkeys- The keys to copy- Returns:
- This
DataManipulator.Mutablewith relevant data filled from the givenValueContainer
-
copyFrom
default DataManipulator.Mutable copyFrom(ValueContainer valueContainer)
Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.Any values that overlaps existing values from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto extract data from- Returns:
- This
DataManipulator.Mutablewith relevant data filled from the givenDataHolder
-
copyFrom
DataManipulator.Mutable copyFrom(ValueContainer valueContainer, MergeFunction overlap)
Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable. Any data that overlaps between this and the givenDataHolderwill be resolved using the givenMergeFunction.Any values that overlaps existing values from the
ValueContainerwill take priority and be overwritten from the pre-existing data from theValueContainer.- Parameters:
valueContainer- TheValueContainerto extract data fromoverlap- The overlap resolver- Returns:
- This
DataManipulator.Mutablewith 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.Mutablewithout having to directly set theValue.Mutableandset(Value)afterwards. The requirement for this to succeed is that theKeymust be checked that it is supported viaValueContainer.supports(Value)orValueContainer.supports(Key)otherwise anIllegalArgumentExceptionmay be thrown. For fluency, after setting, thisDataManipulator.Mutableis 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 supportedValueonto thisDataManipulator.Mutable. The requirement for this to succeed is that theValueis checked for support viaValueContainer.supports(Value)orValueContainer.supports(Key)otherwise anIllegalArgumentExceptionmay be thrown. For fluency, after setting, thisDataManipulator.Mutableis returned.- Parameters:
value- The actual value to set- Returns:
- This manipulator, for chaining
-
set
default DataManipulator.Mutable set(Value<?>... values)
Sets the supportedValues onto thisDataManipulator.Mutable. The requirement for this to succeed is that theValueis checked for support viaValueContainer.supports(Value)orValueContainer.supports(Key)otherwise anIllegalArgumentExceptionmay be thrown. For fluency, after setting, thisDataManipulator.Mutableis 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 supportedValues onto thisDataManipulator.Mutable. The requirement for this to succeed is that theValueis checked for support viaValueContainer.supports(Value)orValueContainer.supports(Key)otherwise anIllegalArgumentExceptionmay be thrown. For fluency, after setting, thisDataManipulator.Mutableis 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:DataManipulatorGets aDataManipulator.Mutablecopy of thisDataManipulatorsuch that all backedValues are copied into theirValue.Mutablecounterparts. Any changes to thisDataManipulatorwill NOT be reflected on the returnedDataManipulator.Mutableand vice versa.The cases where this
DataManipulatoris already aDataManipulator.Mutable, the same manipulator object is returned.- Specified by:
asMutablein interfaceDataManipulator- Returns:
- This
DataManipulator's data copied into aDataManipulator.Mutable
-
copy
DataManipulator.Mutable copy()
Description copied from interface:CopyableValueContainerCreates a clone copy of thisCopyableValueContaineras a newCopyableValueContainersuch that all theValues 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:
copyin interfaceCopyableValueContainer- Specified by:
copyin interfaceDataManipulator- Returns:
- The new copy
-
-