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 Value
s 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
Modifier and TypeInterfaceDescriptionstatic interface
A factory for generatingDataManipulator.Immutable
s.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable
-
Method Summary
Modifier and TypeMethodDescriptiondefault DataManipulator.Immutable
Gets anDataManipulator.Immutable
copy of thisDataManipulator
such that all backedValue.Mutable
s are copied intoValue.Immutable
counterparts.default DataManipulator.Immutable
copy()
Creates a clone copy of thisCopyableValueContainer
as a newCopyableValueContainer
such that all theValue
s are safely duplicated to the new instance.default <E> DataManipulator.Immutable
Applies a transformation on the provided value if the key is available.default <E> DataManipulator.Immutable
Creates a newDataManipulator.Immutable
with the provided value if theKey
is supported by thisDataManipulator.Immutable
without exception.default <E> DataManipulator.Immutable
Creates a newDataManipulator.Immutable
with the providedValue
provided that theValue
is supported by thisDataManipulator.Immutable
.default DataManipulator.Immutable
Creates a newDataManipulator.Immutable
without the givenKey
.Methods inherited from interface org.spongepowered.api.data.DataManipulator
asMutable, asMutableCopy
-
Method Details
-
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
- Specified by:
copy
in interfaceDataManipulator
- Returns:
- The new copy
-
asImmutable
Description copied from interface:DataManipulator
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.- Specified by:
asImmutable
in interfaceDataManipulator
- Returns:
- This
DataManipulator
's data copied into aDataManipulator.Immutable
-
with
Creates a newDataManipulator.Immutable
with the provided value if theKey
is supported by thisDataManipulator.Immutable
without 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.Immutable
without the givenKey
.- Parameters:
key
- The key to use- Returns:
- The new immutable data manipulator
-
with
Creates a newDataManipulator.Immutable
with the providedValue
provided that theValue
is 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
-