Package org.spongepowered.api.data
Interface DataManipulator.Immutable
-
- All Superinterfaces:
CopyableValueContainer
,DataManipulator
,ValueContainer
- Enclosing interface:
- DataManipulator
public static interface DataManipulator.Immutable extends DataManipulator
Represents an immutableDataManipulator
. Immutable meaning that the containedvalues
are all likewiseValue.Immutable
, and as such, cannot be changed themselves, nor can the manipulator be modified to add or remove values. All methods such aswith(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 storedValue
s that their own data does not "expire", cases may include outdated references ofentities
orworlds
that no longer serve valid purposes.- See Also:
- Immutable on Oracle Java Docs
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DataManipulator.Immutable.Factory
A factory for generatingDataManipulator.Immutable
s.-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataManipulator
DataManipulator.Immutable, DataManipulator.Mutable
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default DataManipulator.Immutable
asImmutable()
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
transform(Key<? extends Value<E>> key, Function<E,E> function)
Applies a transformation on the provided value if the key is available.default <E> DataManipulator.Immutable
with(Key<? extends Value<E>> key, E value)
Creates a newDataManipulator.Immutable
with the provided value if theKey
is supported by thisDataManipulator.Immutable
without exception.default <E> DataManipulator.Immutable
with(Value<E> value)
Creates a newDataManipulator.Immutable
with the providedValue
provided that theValue
is supported by thisDataManipulator.Immutable
.default DataManipulator.Immutable
without(Key<?> key)
Creates a newDataManipulator.Immutable
without the givenKey
.-
Methods inherited from interface org.spongepowered.api.data.DataManipulator
asMutable, asMutableCopy
-
-
-
-
Method Detail
-
copy
default DataManipulator.Immutable 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
default DataManipulator.Immutable 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
default <E> DataManipulator.Immutable with(Key<? extends Value<E>> key, E value)
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
default DataManipulator.Immutable without(Key<?> key)
Creates a newDataManipulator.Immutable
without the givenKey
.- Parameters:
key
- The key to use- Returns:
- The new immutable data manipulator
-
with
default <E> DataManipulator.Immutable with(Value<E> value)
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
-
-