Package org.spongepowered.api.data.value
Interface Value.Mutable<E>
- Type Parameters:
E
- The type of element
- All Superinterfaces:
Value<E>
- All Known Subinterfaces:
CollectionValue.Mutable<E,
,C, M, I> ListValue.Mutable<E>
,MapValue.Mutable<K,
,V> SetValue.Mutable<E>
,WeightedCollectionValue.Mutable<E>
Represents a type of
Value
that is mutable. Simply put, the
underlying value can always be changed without creating a new Value.Mutable
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.Value
Value.Factory, Value.Immutable<E>, Value.Mutable<E>
-
Method Summary
Modifier and TypeMethodDescriptionGets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
.default Value.Mutable
<E> Retrieves a mutable form of this value.default Value.Mutable
<E> Retrieves a copy in the mutable form of this value.copy()
Makes an independent copy of thisValue.Mutable
with the same initial data.Sets the underlying value to the providedvalue
.Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.
-
Method Details
-
set
Sets the underlying value to the providedvalue
.- Parameters:
value
- The value to set- Returns:
- The owning
ValueContainer
-
transform
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.- Parameters:
function
- The function to apply on the existing value- Returns:
- The owning
ValueContainer
-
asImmutable
Value.Immutable<E> asImmutable()Gets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
. Note that once created, theValue.Immutable
is not going to change.- Specified by:
asImmutable
in interfaceValue<E>
- Returns:
- A new
Value.Immutable
instance
-
asMutable
Description copied from interface:Value
Retrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Mutable
instance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutable
instance, a new mutable value is created with the same key and values. -
asMutableCopy
Description copied from interface:Value
Retrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopy
in interfaceValue<E>
- Returns:
- A mutable value
-
copy
Value.Mutable<E> copy()Makes an independent copy of thisValue.Mutable
with the same initial data. Both this value and the new value will refer to the same object initially.- Returns:
- A new copy of this
Value.Mutable
-