Interface ReplicatedMultiMap<K,​V>

  • Type Parameters:
    K - The type for keys.
    V - The type for values.
    All Superinterfaces:
    com.akkaserverless.replicatedentity.ReplicatedData

    public interface ReplicatedMultiMap<K,​V>
    extends com.akkaserverless.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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      ReplicatedMultiMap<K,​V> clear()
      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.
      java.util.Set<V> get​(K key)
      Get the values for the given key.
      boolean isEmpty()
      Check whether this multi-map is empty.
      java.util.Set<K> keySet()
      Return the keys contained in this multi-map.
      ReplicatedMultiMap<K,​V> put​(K key, V value)
      Store a key-value pair, if not already present.
      ReplicatedMultiMap<K,​V> putAll​(K key, java.util.Collection<V> values)
      Store multiple values for a key.
      ReplicatedMultiMap<K,​V> remove​(K key, V value)
      Remove a single key-value pair for the given key and value, if present.
      ReplicatedMultiMap<K,​V> removeAll​(K key)
      Remove all values associated with the given key.
      int size()
      Return the number of key-value pairs in this multi-map.
      • Methods inherited from interface com.akkaserverless.replicatedentity.ReplicatedData

        _internal
    • Method Detail

      • get

        java.util.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,
                                             java.util.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

        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

        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

        java.util.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