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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA factory to create newDataManipulator.Mutablemanipulators.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable -
Method Summary
Modifier and TypeMethodDescriptiondefault DataManipulator.MutableGets aDataManipulator.Mutablecopy of thisDataManipulatorsuch that all backedValues are copied into theirValue.Mutablecounterparts.copy()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, Iterable<Key<?>> keys) Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.default DataManipulator.MutablecopyFrom(ValueContainer valueContainer, 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.copyFrom(ValueContainer valueContainer, MergeFunction overlap) Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.copyFrom(ValueContainer valueContainer, MergeFunction overlap, Iterable<Key<?>> keys) Attempts to read data from the givenValueContainerand fills the associated data onto thisDataManipulator.Mutable.copyFrom(ValueContainer valueContainer, MergeFunction overlap, 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.default DataManipulator.MutableSets the supportedValues 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.Mutablewithout having to directly set theValue.Mutableandset(Value)afterwards.default DataManipulator.MutableSets the supportedValueonto thisDataManipulator.Mutable.default DataManipulator.MutableSets the supportedValues onto thisDataManipulator.Mutable.default <E> DataManipulator.MutableApplies 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 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, 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
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, 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
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
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
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
-
set
default <E,V extends Value<E>> DataManipulator.Mutable set(Supplier<Key<V>> key, Supplier<E> value) -
set
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
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
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
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: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
-