Package org.spongepowered.api.data.value
Interface MapValue.Immutable<K,V>
-
- Type Parameters:
K- The type of the keyV- The type of the value
- All Superinterfaces:
MapValue<K,V>,Value<java.util.Map<K,V>>,Value.Immutable<java.util.Map<K,V>>
public static interface MapValue.Immutable<K,V> extends MapValue<K,V>, Value.Immutable<java.util.Map<K,V>>
Represents a specialized type ofValue.Immutablethat is different from anCollectionValue.Immutablesuch 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 default MapValue.Immutable<K,V>asImmutable()Retrieves an immutable form of this value.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.Immutable<K,V>transform(java.util.function.Function<java.util.Map<K,V>,java.util.Map<K,V>> function)Retrieves the underlying value for thisValue.Immutableand applies the givenFunctiononto that value, after which, the product is sent to a newValue.Immutablereplacing this one.MapValue.Immutable<K,V>with(java.util.Map<K,V> value)Creates a newValue.Immutablewith the givenEtyped value, such that if the owningValueContaineris immutable, theValueContainertoo is recreated as a new instance with the newValue.Immutable.MapValue.Immutable<K,V>with(K key, V value)Associates the provided key to the provided value in the new map.MapValue.Immutable<K,V>withAll(java.util.Map<K,V> map)Associates all providedMap.Entryalong with all pre-existing map entries in a newMapValue.Immutable.MapValue.Immutable<K,V>without(K key)Creates a newMapValue.Immutablewithout the provided key and the associated value.MapValue.Immutable<K,V>withoutAll(java.lang.Iterable<K> keys)Creates a newMapValue.Immutablewithout the provided keys and their associated values.MapValue.Immutable<K,V>withoutAll(java.util.function.Predicate<java.util.Map.Entry<K,V>> predicate)Creates a newMapValue.Immutablesuch that all entries are filtered by the providedPredicate, any that returntrueare retained in the new value.-
Methods inherited from interface org.spongepowered.api.data.value.MapValue
containsKey, containsValue, entrySet, key, keySet, size, values
-
-
-
-
Method Detail
-
with
MapValue.Immutable<K,V> with(K key, V value)
Associates the provided key to the provided value in the new map. 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:
- The new value, for chaining
-
withAll
MapValue.Immutable<K,V> withAll(java.util.Map<K,V> map)
Associates all providedMap.Entryalong with all pre-existing map entries in a newMapValue.Immutable.- Parameters:
map- The map of key values to set- Returns:
- The new value, for chaining
-
without
MapValue.Immutable<K,V> without(K key)
Creates a newMapValue.Immutablewithout the provided key and the associated value.- Parameters:
key- The key to exclude the association- Returns:
- The new value, for chaining
-
withoutAll
MapValue.Immutable<K,V> withoutAll(java.lang.Iterable<K> keys)
Creates a newMapValue.Immutablewithout the provided keys and their associated values.- Parameters:
keys- The keys to exclude- Returns:
- The new value, for chaining
-
withoutAll
MapValue.Immutable<K,V> withoutAll(java.util.function.Predicate<java.util.Map.Entry<K,V>> predicate)
Creates a newMapValue.Immutablesuch that all entries are filtered by the providedPredicate, any that returntrueare retained in the new value. Elements that returntruefromPredicate.test(Object)are kept, and those that returnfalseare excluded.- Parameters:
predicate- The predicate to filter- Returns:
- The new value, for chaining
-
with
MapValue.Immutable<K,V> with(java.util.Map<K,V> value)
Description copied from interface:Value.ImmutableCreates a newValue.Immutablewith the givenEtyped value, such that if the owningValueContaineris immutable, theValueContainertoo is recreated as a new instance with the newValue.Immutable.- Specified by:
within interfaceValue.Immutable<K>- Parameters:
value- The value to replace- Returns:
- The owning
ValueContainer, a new instance if it too is immutable
-
transform
MapValue.Immutable<K,V> transform(java.util.function.Function<java.util.Map<K,V>,java.util.Map<K,V>> function)
Description copied from interface:Value.ImmutableRetrieves the underlying value for thisValue.Immutableand applies the givenFunctiononto that value, after which, the product is sent to a newValue.Immutablereplacing this one.If the
ValueContainertoo is immutable, a new instance of theValueContainermay be created. If theValueContaineris mutable, the same instance of theValueContaineris retained.- Specified by:
transformin interfaceValue.Immutable<K>- Parameters:
function- The function to apply onto the existing value- Returns:
- The owning
ValueContainer, a new instance if it too is immutable
-
asMutable
MapValue.Mutable<K,V> 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
default MapValue.Mutable<K,V> 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 interfaceMapValue<K,V>- Specified by:
asMutableCopyin interfaceValue<K>- Specified by:
asMutableCopyin interfaceValue.Immutable<K>- Returns:
- A mutable value
-
asImmutable
default MapValue.Immutable<K,V> asImmutable()
Description copied from interface:ValueRetrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Immutableinstance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutableinstance, a new immutable value is created with the same key and values.- Specified by:
asImmutablein interfaceMapValue<K,V>- Specified by:
asImmutablein interfaceValue<K>- Specified by:
asImmutablein interfaceValue.Immutable<K>- Returns:
- An immutable value
-
-