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.Immutableversion of thisValue.Mutablesuch 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.Mutablewith the same initial data.Sets the underlying value to the providedvalue.Attempts to transform the underlying value based on the providedFunctionsuch 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 providedFunctionsuch 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.Immutableversion of thisValue.Mutablesuch that all data is duplicated across to the newValue.Immutable. Note that once created, theValue.Immutableis not going to change.- Specified by:
asImmutablein interfaceValue<E>- Returns:
- A new
Value.Immutableinstance
-
asMutable
Description copied from interface:ValueRetrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Mutableinstance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutableinstance, a new mutable value is created with the same key and values. -
asMutableCopy
Description copied from interface:ValueRetrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopyin interfaceValue<E>- Returns:
- A mutable value
-
copy
Value.Mutable<E> copy()Makes an independent copy of thisValue.Mutablewith 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
-