Package org.spongepowered.api.data
Interface DataManipulator
- All Superinterfaces:
CopyableValueContainer,ValueContainer
- All Known Subinterfaces:
DataManipulator.Immutable,DataManipulator.Mutable
Represents a changelist of data that can be applied to a
DataHolder.Mutable.
With a DataManipulator, specific sets of mutable data can be
represented and changed outside the live state of the DataHolder.Mutable.
DataManipulators are serializable such that they can be serialized
and deserialized from persistence, and applied to DataHolders, even
with specialized Functions to use DataManipulator.Mutable.transform(Key, Function)
such that the DataManipulator is always returned.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents an immutableDataManipulator.static interfaceRepresents a changelist of data that can be applied to aDataHolder. -
Method Summary
Modifier and TypeMethodDescriptionGets anDataManipulator.Immutablecopy of thisDataManipulatorsuch that all backedValue.Mutables are copied intoValue.Immutablecounterparts.Gets aDataManipulator.Mutablecopy of thisDataManipulatorsuch that all backedValues are copied into theirValue.Mutablecounterparts.Creates a newDataManipulator.Mutablecopy of allValuescontained in thisDataManipulator, regardless whether this is amutableinstance already.copy()Creates a clone copy of thisCopyableValueContaineras a newCopyableValueContainersuch that all theValues are safely duplicated to the new instance.static DataManipulator.ImmutableGets 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.MutableCreates an emptyDataManipulator.Mutablemanipulator that can be consumed, populated, and mutated at liberty.static DataManipulator.MutableCreates 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 Details
-
immutableOf
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
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
Gets a emptyDataManipulator.Immutable.- Returns:
- The empty immutable data manipulator
-
mutableOf
Creates an emptyDataManipulator.Mutablemanipulator that can be consumed, populated, and mutated at liberty.- Returns:
- A new empty manipulator
-
mutableOf
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
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
-