Package org.spongepowered.api.data
Interface DataManipulator
-
- All Superinterfaces:
CopyableValueContainer,ValueContainer
- All Known Subinterfaces:
DataManipulator.Immutable,DataManipulator.Mutable
public interface DataManipulator extends CopyableValueContainer
Represents a changelist of data that can be applied to aDataHolder.Mutable. With aDataManipulator, specific sets of mutable data can be represented and changed outside the live state of theDataHolder.Mutable.DataManipulators are serializable such that they can be serialized and deserialized from persistence, and applied toDataHolders, even with specializedFunctions to useDataManipulator.Mutable.transform(Key, Function)such that theDataManipulatoris always returned.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDataManipulator.ImmutableRepresents an immutableDataManipulator.static interfaceDataManipulator.MutableRepresents a changelist of data that can be applied to aDataHolder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description DataManipulator.ImmutableasImmutable()Gets anDataManipulator.Immutablecopy of thisDataManipulatorsuch that all backedValue.Mutables are copied intoValue.Immutablecounterparts.DataManipulator.MutableasMutable()Gets aDataManipulator.Mutablecopy of thisDataManipulatorsuch that all backedValues are copied into theirValue.Mutablecounterparts.DataManipulator.MutableasMutableCopy()Creates a newDataManipulator.Mutablecopy of allValuescontained in thisDataManipulator, regardless whether this is amutableinstance already.DataManipulatorcopy()Creates a clone copy of thisCopyableValueContaineras a newCopyableValueContainersuch that all theValues are safely duplicated to the new instance.static DataManipulator.ImmutableimmutableOf()Gets a emptyDataManipulator.Immutable.static DataManipulator.ImmutableimmutableOf(Iterable<? extends Value<?>> values)Creates aDataManipulator.Immutableview directly based on theValues.static DataManipulator.ImmutableimmutableOf(ValueContainer valueContainer)Creates anDataManipulator.Immutableview directly based on theValues provided by the givenValueContainer, such that allValueContainer.getValues()will be converted viaValue.asImmutable()and constructed into anDataManipulator.Immutable.static DataManipulator.MutablemutableOf()Creates an emptyDataManipulator.Mutablemanipulator that can be consumed, populated, and mutated at liberty.static DataManipulator.MutablemutableOf(Iterable<? extends Value<?>> values)Creates a newDataManipulatorwith the providedValuessuch that the resultingDataManipulator.Mutablewill contain all saidvalues.static DataManipulator.MutablemutableOf(ValueContainer valueContainer)Creates a newDataManipulatorwith allvaluesretrievable through the givenValueContainerbyValueContainer.getValues()with the connotation that allValues are provided, even those that are not persisted or registered through aDataRegistration.
-
-
-
Method Detail
-
immutableOf
static DataManipulator.Immutable immutableOf(Iterable<? extends Value<?>> values)
Creates aDataManipulator.Immutableview directly based on theValues. No unnecessary copies of theValues will be created.- Parameters:
values- The values- Returns:
- The immutable data manipulator view
-
immutableOf
static DataManipulator.Immutable immutableOf(ValueContainer valueContainer)
Creates anDataManipulator.Immutableview directly based on theValues provided by the givenValueContainer, such that allValueContainer.getValues()will be converted viaValue.asImmutable()and constructed into anDataManipulator.Immutable.- Parameters:
valueContainer- The value container to populate values from- Returns:
- The immutable manipulator
-
immutableOf
static DataManipulator.Immutable immutableOf()
Gets a emptyDataManipulator.Immutable.- Returns:
- The empty immutable data manipulator
-
mutableOf
static DataManipulator.Mutable mutableOf()
Creates an emptyDataManipulator.Mutablemanipulator that can be consumed, populated, and mutated at liberty.- Returns:
- A new empty manipulator
-
mutableOf
static DataManipulator.Mutable mutableOf(Iterable<? extends Value<?>> values)
Creates a newDataManipulatorwith the providedValuessuch that the resultingDataManipulator.Mutablewill contain all saidvalues. The returnedmanipulatoris stillmutable.- Parameters:
values- The values to populate the mutable container- Returns:
- The mutable manipulator containing all values
-
mutableOf
static DataManipulator.Mutable mutableOf(ValueContainer valueContainer)
Creates a newDataManipulatorwith allvaluesretrievable through the givenValueContainerbyValueContainer.getValues()with the connotation that allValues are provided, even those that are not persisted or registered through aDataRegistration.- Parameters:
valueContainer- The value container providing all values- Returns:
- The mutable manipulator containing all values
-
copy
DataManipulator 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- Returns:
- The new copy
-
asMutableCopy
DataManipulator.Mutable asMutableCopy()
Creates a newDataManipulator.Mutablecopy of allValuescontained in thisDataManipulator, regardless whether this is amutableinstance already. Changes to this container will NOT persist to the copied instance. This is different fromcopy()as the copied instance may not beDataManipulator.Mutable.- Returns:
- The copied instance
-
asMutable
DataManipulator.Mutable asMutable()
Gets 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.- Returns:
- This
DataManipulator's data copied into aDataManipulator.Mutable
-
asImmutable
DataManipulator.Immutable asImmutable()
Gets anDataManipulator.Immutablecopy of thisDataManipulatorsuch that all backedValue.Mutables are copied intoValue.Immutablecounterparts. Any changes to thisDataManipulatorwill NOT be reflected on the returnedDataManipulator.Immutableand vice versa.- Returns:
- This
DataManipulator's data copied into aDataManipulator.Immutable
-
-