Package kalix.javasdk.replicatedentity
Interface ReplicatedMultiMap<K,V>
- Type Parameters:
K
- The type for keys.V
- The type for values.
- All Superinterfaces:
kalix.replicatedentity.ReplicatedData
public interface ReplicatedMultiMap<K,V>
extends kalix.replicatedentity.ReplicatedData
A replicated map that maps keys to values, where each key may be associated with multiple values.
Effectively a ReplicatedMap with
ReplicatedSet
s as values.-
Method Summary
Modifier and TypeMethodDescriptionclear()
Remove all key-value pairs from the multi-map, leaving it empty.boolean
containsKey
(K key) Check whether this multi-map contains at least one value for the given key.boolean
containsValue
(K key, V value) Check whether this multi-map contains the given value associated with the given key.Get the values for the given key.boolean
isEmpty()
Check whether this multi-map is empty.keySet()
Return the keys contained in this multi-map.Store a key-value pair, if not already present.putAll
(K key, Collection<V> values) Store multiple values for a key.Remove a single key-value pair for the given key and value, if present.Remove all values associated with the given key.int
size()
Return the number of key-value pairs in this multi-map.
-
Method Details
-
get
Get the values for the given key.- Parameters:
key
- the key of the mapping- Returns:
- the current values at the given key, or an empty Set
-
put
Store a key-value pair, if not already present.- Parameters:
key
- the key of the mapping to add tovalue
- the value to add to the mapping- Returns:
- a new multi-map with the additional value, or this unchanged multi-map
-
putAll
Store multiple values for a key.- Parameters:
key
- the key of the mapping to add tovalues
- the values to add to the mapping- Returns:
- a new multi-map with the additional values, or this unchanged multi-map
-
remove
Remove a single key-value pair for the given key and value, if present.- Parameters:
key
- the key of the mapping to remove fromvalue
- the value to remove from the mapping- Returns:
- a new multi-map with the removed value, or this unchanged multi-map
-
removeAll
Remove all values associated with the given key.- Parameters:
key
- the key of the mapping to remove- Returns:
- a new multi-map with the removed mapping
-
clear
ReplicatedMultiMap<K,V> clear()Remove all key-value pairs from the multi-map, leaving it empty.- Returns:
- a new empty multi-map
-
size
int size()Return the number of key-value pairs in this multi-map.Note that this does not return the number of distinct keys, which is given by
keySet().size()
, but the total number of values stored in the multi-map.- Returns:
- the number of key-value pairs stored in this multi-map
-
isEmpty
boolean isEmpty()Check whether this multi-map is empty.- Returns:
true
if this multi-map contains no key-value pairs
-
containsKey
Check whether this multi-map contains at least one value for the given key.- Parameters:
key
- the key of the mapping to check- Returns:
true
if there is at least one key-value pair for the key
-
containsValue
Check whether this multi-map contains the given value associated with the given key.- Parameters:
key
- the key of the mapping to checkvalue
- the value of the mapping to check- Returns:
true
if the key-value pair is in this multi-map
-
keySet
Return the keys contained in this multi-map.Note that the key set contains a key if and only if this multi-map maps that key to at least one value.
- Returns:
- the set of keys in this multi-map
-