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
.
DataManipulator
s are serializable such that they can be serialized
and deserialized from persistence, and applied to DataHolder
s, even
with specialized Function
s to use DataManipulator.Mutable.transform(Key, Function)
such that the DataManipulator
is always returned.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Represents an immutableDataManipulator
.static interface
Represents a changelist of data that can be applied to aDataHolder
. -
Method Summary
Modifier and TypeMethodDescriptionGets anDataManipulator.Immutable
copy of thisDataManipulator
such that all backedValue.Mutable
s are copied intoValue.Immutable
counterparts.Gets aDataManipulator.Mutable
copy of thisDataManipulator
such that all backedValue
s are copied into theirValue.Mutable
counterparts.Creates a newDataManipulator.Mutable
copy of allValues
contained in thisDataManipulator
, regardless whether this is amutable
instance already.copy()
Creates a clone copy of thisCopyableValueContainer
as a newCopyableValueContainer
such that all theValue
s are safely duplicated to the new instance.static DataManipulator.Immutable
Gets a emptyDataManipulator.Immutable
.static DataManipulator.Immutable
immutableOf
(Iterable<? extends Value<?>> values) Creates aDataManipulator.Immutable
view directly based on theValue
s.static DataManipulator.Immutable
immutableOf
(ValueContainer valueContainer) Creates anDataManipulator.Immutable
view directly based on theValue
s provided by the givenValueContainer
, such that allValueContainer.getValues()
will be converted viaValue.asImmutable()
and constructed into anDataManipulator.Immutable
.static DataManipulator.Mutable
Creates an emptyDataManipulator.Mutable
manipulator that can be consumed, populated, and mutated at liberty.static DataManipulator.Mutable
Creates a newDataManipulator
with the providedValues
such that the resultingDataManipulator.Mutable
will contain all saidvalues
.static DataManipulator.Mutable
mutableOf
(ValueContainer valueContainer) Creates a newDataManipulator
with allvalues
retrievable through the givenValueContainer
byValueContainer.getValues()
with the connotation that allValue
s are provided, even those that are not persisted or registered through aDataRegistration
.
-
Method Details
-
immutableOf
Creates aDataManipulator.Immutable
view directly based on theValue
s. No unnecessary copies of theValue
s will be created.- Parameters:
values
- The values- Returns:
- The immutable data manipulator view
-
immutableOf
Creates anDataManipulator.Immutable
view directly based on theValue
s 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.Mutable
manipulator that can be consumed, populated, and mutated at liberty.- Returns:
- A new empty manipulator
-
mutableOf
Creates a newDataManipulator
with the providedValues
such that the resultingDataManipulator.Mutable
will contain all saidvalues
. The returnedmanipulator
is stillmutable
.- Parameters:
values
- The values to populate the mutable container- Returns:
- The mutable manipulator containing all values
-
mutableOf
Creates a newDataManipulator
with allvalues
retrievable through the givenValueContainer
byValueContainer.getValues()
with the connotation that allValue
s 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: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
- Returns:
- The new copy
-
asMutableCopy
DataManipulator.Mutable asMutableCopy()Creates a newDataManipulator.Mutable
copy of allValues
contained in thisDataManipulator
, regardless whether this is amutable
instance 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.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.- Returns:
- This
DataManipulator
's data copied into aDataManipulator.Mutable
-
asImmutable
DataManipulator.Immutable asImmutable()Gets anDataManipulator.Immutable
copy of thisDataManipulator
such that all backedValue.Mutable
s are copied intoValue.Immutable
counterparts. Any changes to thisDataManipulator
will NOT be reflected on the returnedDataManipulator.Immutable
and vice versa.- Returns:
- This
DataManipulator
's data copied into aDataManipulator.Immutable
-