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>
public static interface Value.Mutable<E> extends Value<E>
Represents a type ofValue
that is mutable. Simply put, the underlying value can always be changed without creating a newValue.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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Value.Immutable<E>
asImmutable()
Gets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
.default Value.Mutable<E>
asMutable()
Retrieves a mutable form of this value.default Value.Mutable<E>
asMutableCopy()
Retrieves a copy in the mutable form of this value.Value.Mutable<E>
copy()
Makes an independent copy of thisValue.Mutable
with the same initial data.Value.Mutable<E>
set(E value)
Sets the underlying value to the providedvalue
.Value.Mutable<E>
transform(Function<E,E> function)
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.
-
-
-
Method Detail
-
set
Value.Mutable<E> set(E value)
Sets the underlying value to the providedvalue
.- Parameters:
value
- The value to set- Returns:
- The owning
ValueContainer
-
transform
Value.Mutable<E> transform(Function<E,E> function)
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
default Value.Mutable<E> 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
default Value.Mutable<E> 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
-
-