Package org.spongepowered.api.data
Interface DataManipulator.Immutable
- All Superinterfaces:
CopyableValueContainer,DataManipulator,ValueContainer
- Enclosing interface:
- DataManipulator
Represents an immutable
DataManipulator. Immutable meaning that
the contained values are all likewise
Value.Immutable, and as such,
cannot be changed themselves, nor can the manipulator be modified to add
or remove values. All methods such as with(Value) return new
instances. It is guaranteed to be thread safe to access values from this
container, and seeing as it does not change, can be passed around as a
pseudo cache for templating. It is important to note that there is no
guarantee on the validity of the stored Values that their own data
does not "expire", cases may include outdated references of
entities or worlds that no longer serve valid
purposes.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA factory for generatingDataManipulator.Immutables.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable -
Method Summary
Modifier and TypeMethodDescriptiondefault DataManipulator.ImmutableGets anDataManipulator.Immutablecopy of thisDataManipulatorsuch that all backedValue.Mutables are copied intoValue.Immutablecounterparts.default DataManipulator.Immutablecopy()Creates a clone copy of thisCopyableValueContaineras a newCopyableValueContainersuch that all theValues are safely duplicated to the new instance.default <E> DataManipulator.ImmutableApplies a transformation on the provided value if the key is available.default <E> DataManipulator.ImmutableCreates a newDataManipulator.Immutablewith the provided value if theKeyis supported by thisDataManipulator.Immutablewithout exception.default <E> DataManipulator.ImmutableCreates a newDataManipulator.Immutablewith the providedValueprovided that theValueis supported by thisDataManipulator.Immutable.default DataManipulator.ImmutableCreates a newDataManipulator.Immutablewithout the givenKey.Methods inherited from interface org.spongepowered.api.data.DataManipulator
asMutable, asMutableCopy
-
Method Details
-
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
-
asImmutable
Description copied from interface:DataManipulatorGets 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.- Specified by:
asImmutablein interfaceDataManipulator- Returns:
- This
DataManipulator's data copied into aDataManipulator.Immutable
-
with
Creates a newDataManipulator.Immutablewith the provided value if theKeyis supported by thisDataManipulator.Immutablewithout exception.- Type Parameters:
E- The type of value- Parameters:
key- The key to usevalue- The value to set- Returns:
- The new immutable data manipulator
-
without
Creates a newDataManipulator.Immutablewithout the givenKey.- Parameters:
key- The key to use- Returns:
- The new immutable data manipulator
-
with
Creates a newDataManipulator.Immutablewith the providedValueprovided that theValueis supported by thisDataManipulator.Immutable.- Type Parameters:
E- The type of value- Parameters:
value- The value to set- Returns:
- The new immutable data manipulator
-
transform
default <E> DataManipulator.Immutable transform(Key<? extends Value<E>> key, Function<E, E> function) Applies a transformation on the provided value if the key is available. This is the same asDataHolder.Immutable.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
-