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>>
public static interface MapValue.Immutable<K,V> extends MapValue<K,V>, Value.Immutable<Map<K,V>>
Represents a specialized type ofValue.Immutable
that is different from anCollectionValue.Immutable
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 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(Function<Map<K,V>,Map<K,V>> function)
Retrieves the underlying value for thisValue.Immutable
and applies the givenFunction
onto that value, after which, the product is sent to a newValue.Immutable
replacing this one.MapValue.Immutable<K,V>
with(Map<K,V> value)
Creates a newValue.Immutable
with the givenE
typed value, such that if the owningValueContainer
is immutable, theValueContainer
too 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(Map<K,V> map)
Associates all providedMap.Entry
along with all pre-existing map entries in a newMapValue.Immutable
.MapValue.Immutable<K,V>
without(K key)
Creates a newMapValue.Immutable
without the provided key and the associated value.MapValue.Immutable<K,V>
withoutAll(Iterable<K> keys)
Creates a newMapValue.Immutable
without the provided keys and their associated values.MapValue.Immutable<K,V>
withoutAll(Predicate<Map.Entry<K,V>> predicate)
Creates a newMapValue.Immutable
such that all entries are filtered by the providedPredicate
, any that returntrue
are 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(Map<K,V> map)
Associates all providedMap.Entry
along 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.Immutable
without 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(Iterable<K> keys)
Creates a newMapValue.Immutable
without 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(Predicate<Map.Entry<K,V>> predicate)
Creates a newMapValue.Immutable
such that all entries are filtered by the providedPredicate
, any that returntrue
are retained in the new value. Elements that returntrue
fromPredicate.test(Object)
are kept, and those that returnfalse
are excluded.- Parameters:
predicate
- The predicate to filter- Returns:
- The new value, for chaining
-
with
MapValue.Immutable<K,V> with(Map<K,V> value)
Description copied from interface:Value.Immutable
Creates a newValue.Immutable
with the givenE
typed value, such that if the owningValueContainer
is immutable, theValueContainer
too is recreated as a new instance with the newValue.Immutable
.- Specified by:
with
in 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(Function<Map<K,V>,Map<K,V>> function)
Description copied from interface:Value.Immutable
Retrieves the underlying value for thisValue.Immutable
and applies the givenFunction
onto that value, after which, the product is sent to a newValue.Immutable
replacing this one.If the
ValueContainer
too is immutable, a new instance of theValueContainer
may be created. If theValueContainer
is mutable, the same instance of theValueContainer
is retained.- Specified by:
transform
in 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: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.Immutable<K>
- Returns:
- A mutable value
-
asImmutable
default 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.Immutable<K>
- Returns:
- An immutable value
-
-