Package org.spongepowered.api.data.value
Interface MapValue.Mutable<K,V>
-
- Type Parameters:
K
- The type of the keyV
- The type of the value
- All Superinterfaces:
MapValue<K,V>
,Value<Map<K,V>>
,Value.Mutable<Map<K,V>>
public static interface MapValue.Mutable<K,V> extends MapValue<K,V>, Value.Mutable<Map<K,V>>
Represents a specialized type ofValue.Mutable
that is different from aCollectionValue.Mutable
such that the "elements" areMap.Entry
. Usually, this type of value is used to represent a particular "type" of "key" that is associated to a particular "value".
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.MapValue
MapValue.Immutable<K,V>, MapValue.Mutable<K,V>
-
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 MapValue.Immutable<K,V>
asImmutable()
Retrieves an immutable form of this value.default MapValue.Mutable<K,V>
asMutable()
Retrieves a mutable form of this value.default MapValue.Mutable<K,V>
asMutableCopy()
Retrieves a copy in the mutable form of this value.MapValue.Mutable<K,V>
copy()
Makes an independent copy of thisValue.Mutable
with the same initial data.MapValue.Mutable<K,V>
put(K key, V value)
Associates the provided key to the provided value.MapValue.Mutable<K,V>
putAll(Map<K,V> map)
Associates all providedMap.Entry
to this map value.MapValue.Mutable<K,V>
remove(K key)
Removes the association of the provided key to the value currently associated.MapValue.Mutable<K,V>
removeAll(Iterable<K> keys)
Removes all key value associations of the provided keys.MapValue.Mutable<K,V>
removeAll(Predicate<Map.Entry<K,V>> predicate)
MapValue.Mutable<K,V>
set(Map<K,V> value)
Sets the underlying value to the providedvalue
.MapValue.Mutable<K,V>
transform(Function<Map<K,V>,Map<K,V>> function)
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.-
Methods inherited from interface org.spongepowered.api.data.value.MapValue
containsKey, containsValue, entrySet, key, keySet, size, values
-
-
-
-
Method Detail
-
put
MapValue.Mutable<K,V> put(K key, V value)
Associates the provided key to the provided value. If there already exists a value for the provided key, the value is replaced.- Parameters:
key
- The key to associate to the valuevalue
- The value associated with the key- Returns:
- This map value, for chaining
-
putAll
MapValue.Mutable<K,V> putAll(Map<K,V> map)
Associates all providedMap.Entry
to this map value.- Parameters:
map
- The map of key values to set- Returns:
- This map value, for chaining
-
remove
MapValue.Mutable<K,V> remove(K key)
Removes the association of the provided key to the value currently associated.- Parameters:
key
- The key to remove- Returns:
- This map value, for chaining
-
removeAll
MapValue.Mutable<K,V> removeAll(Iterable<K> keys)
Removes all key value associations of the provided keys.- Parameters:
keys
- The keys to remove- Returns:
- This map value, for chaining
-
removeAll
MapValue.Mutable<K,V> removeAll(Predicate<Map.Entry<K,V>> predicate)
Applies thePredicate
to allMap.Entry
within thisMapValue.Mutable
. Any entries that are false will be removed from the map value.- Parameters:
predicate
- The predicate to filer- Returns:
- This map value, for chaining
-
set
MapValue.Mutable<K,V> set(Map<K,V> value)
Description copied from interface:Value.Mutable
Sets the underlying value to the providedvalue
.- Specified by:
set
in interfaceValue.Mutable<K>
- Parameters:
value
- The value to set- Returns:
- The owning
ValueContainer
-
transform
MapValue.Mutable<K,V> transform(Function<Map<K,V>,Map<K,V>> function)
Description copied from interface:Value.Mutable
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.- Specified by:
transform
in interfaceValue.Mutable<K>
- Parameters:
function
- The function to apply on the existing value- Returns:
- The owning
ValueContainer
-
copy
MapValue.Mutable<K,V> copy()
Description copied from interface:Value.Mutable
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.- Specified by:
copy
in interfaceValue.Mutable<K>
- Returns:
- A new copy of this
Value.Mutable
-
asMutable
default MapValue.Mutable<K,V> 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 MapValue.Mutable<K,V> 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 interfaceMapValue<K,V>
- Specified by:
asMutableCopy
in interfaceValue<K>
- Specified by:
asMutableCopy
in interfaceValue.Mutable<K>
- Returns:
- A mutable value
-
asImmutable
MapValue.Immutable<K,V> asImmutable()
Description copied from interface:Value
Retrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Immutable
instance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutable
instance, a new immutable value is created with the same key and values.- Specified by:
asImmutable
in interfaceMapValue<K,V>
- Specified by:
asImmutable
in interfaceValue<K>
- Specified by:
asImmutable
in interfaceValue.Mutable<K>
- Returns:
- An immutable value
-
-