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 ReplicatedSets as values.
  • Method Summary

    Modifier and Type
    Method
    Description
    Remove all key-value pairs from the multi-map, leaving it empty.
    boolean
    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(K key)
    Get the values for the given key.
    boolean
    Check whether this multi-map is empty.
    Return the keys contained in this multi-map.
    put(K key, V value)
    Store a key-value pair, if not already present.
    putAll(K key, Collection<V> values)
    Store multiple values for a key.
    remove(K key, V value)
    Remove a single key-value pair for the given key and value, if present.
    removeAll(K key)
    Remove all values associated with the given key.
    int
    Return the number of key-value pairs in this multi-map.
  • Method Details

    • get

      Set<V> get(K key)
      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

      ReplicatedMultiMap<K,V> put(K key, V value)
      Store a key-value pair, if not already present.
      Parameters:
      key - the key of the mapping to add to
      value - the value to add to the mapping
      Returns:
      a new multi-map with the additional value, or this unchanged multi-map
    • putAll

      ReplicatedMultiMap<K,V> putAll(K key, Collection<V> values)
      Store multiple values for a key.
      Parameters:
      key - the key of the mapping to add to
      values - the values to add to the mapping
      Returns:
      a new multi-map with the additional values, or this unchanged multi-map
    • remove

      ReplicatedMultiMap<K,V> remove(K key, V value)
      Remove a single key-value pair for the given key and value, if present.
      Parameters:
      key - the key of the mapping to remove from
      value - the value to remove from the mapping
      Returns:
      a new multi-map with the removed value, or this unchanged multi-map
    • removeAll

      ReplicatedMultiMap<K,V> removeAll(K key)
      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

      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

      boolean containsKey(K key)
      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

      boolean containsValue(K key, V value)
      Check whether this multi-map contains the given value associated with the given key.
      Parameters:
      key - the key of the mapping to check
      value - the value of the mapping to check
      Returns:
      true if the key-value pair is in this multi-map
    • keySet

      Set<K> 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