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<Map<K,,V>> Value.Immutable<Map<K,V>>
Represents a specialized type of
Value.Immutable that is different
from an CollectionValue.Immutable such that the "elements" are
Map.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
Modifier and TypeMethodDescriptiondefault MapValue.Immutable<K,V> Retrieves an immutable form of this value.Retrieves a mutable form of this value.default MapValue.Mutable<K,V> Retrieves a copy in the mutable form of this value.Retrieves the underlying value for thisValue.Immutableand applies the givenFunctiononto that value, after which, the product is sent to a newValue.Immutablereplacing this one.Creates a newValue.Immutablewith the givenEtyped value, such that if the owningValueContaineris immutable, theValueContainertoo is recreated as a new instance with the newValue.Immutable.Associates the provided key to the provided value in the new map.Associates all providedMap.Entryalong with all pre-existing map entries in a newMapValue.Immutable.Creates a newMapValue.Immutablewithout the provided key and the associated value.withoutAll(Iterable<K> keys) Creates a newMapValue.Immutablewithout the provided keys and their associated values.withoutAll(Predicate<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 Details
-
with
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
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
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
Creates a newMapValue.Immutablewithout the provided keys and their associated values.- Parameters:
keys- The keys to exclude- Returns:
- The new value, for chaining
-
withoutAll
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
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
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
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
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
-