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
.DataManipulator
s are serializable such that they can be serialized and deserialized from persistence, and applied toDataHolder
s, even with specializedFunction
s to useDataManipulator.Mutable.transform(Key, Function)
such that theDataManipulator
is always returned.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DataManipulator.Immutable
Represents an immutableDataManipulator
.static interface
DataManipulator.Mutable
Represents 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.Immutable
asImmutable()
Gets anDataManipulator.Immutable
copy of thisDataManipulator
such that all backedValue.Mutable
s are copied intoValue.Immutable
counterparts.DataManipulator.Mutable
asMutable()
Gets aDataManipulator.Mutable
copy of thisDataManipulator
such that all backedValue
s are copied into theirValue.Mutable
counterparts.DataManipulator.Mutable
asMutableCopy()
Creates a newDataManipulator.Mutable
copy of allValues
contained in thisDataManipulator
, regardless whether this is amutable
instance already.DataManipulator
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
immutableOf()
Gets a emptyDataManipulator.Immutable
.static DataManipulator.Immutable
immutableOf(java.lang.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
mutableOf()
Creates an emptyDataManipulator.Mutable
manipulator that can be consumed, populated, and mutated at liberty.static DataManipulator.Mutable
mutableOf(java.lang.Iterable<? extends Value<?>> values)
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 Detail
-
immutableOf
static DataManipulator.Immutable immutableOf(java.lang.Iterable<? extends Value<?>> values)
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
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
.- 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.Mutable
manipulator that can be consumed, populated, and mutated at liberty.- Returns:
- A new empty manipulator
-
mutableOf
static DataManipulator.Mutable mutableOf(java.lang.Iterable<? extends Value<?>> values)
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
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
.- 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
-
-