Interface Multimap<K,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      Map<K,​Collection<V>> asMap()
      A map representation of the multimap where the values are represented in a Collection.
      default void clear()
      Clears all items in the multimap
      default boolean contains​(Object key, Object value)
      Checks if the given key and value exist in the multimap
      default boolean containsKey​(Object key)
      Checks if the key is contained in the multimap
      default boolean containsValue​(Object value)
      Checks if the value exists in the multimap
      default Set<Map.Entry<K,​V>> entries()
      A set of the entries in the multimap
      Collection<V> get​(Object key)
      Gets the values mapped to by the given key.
      default boolean isEmpty()
      Checks if the multimap is empty, i.e.
      default Set<K> keySet()
      Gets the set of keys in the multimap
      default boolean put​(K key, V value)
      Puts the key-value pair mapping in the multimap
      default void putAll​(@NonNull Multimap<? extends K,​? extends V> multimap)
      Put all key-value pairs in the multimap
      default void putAll​(@NonNull Map<? extends K,​? extends Collection<? extends V>> map)
      Put all key-value pairs in the multimap
      default void putAll​(K key, Iterable<? extends V> values)
      Puts all values for a given key
      default boolean remove​(Object key, Object value)
      Removes the given key-value pair from the multimap
      Collection<V> removeAll​(Object key)
      Removes all values for the given key.
      void replace​(K key, Iterable<? extends V> values)
      Replaces the values for a given key with the given new values
      default int size()
      The number of key-value mappings in the multimap
      default Collection<V> values()
      Provides a view of the values in the multimap
    • Method Detail

      • asMap

        Map<K,​Collection<V>> asMap()
        A map representation of the multimap where the values are represented in a Collection.
        Returns:
        the map
      • clear

        default void clear()
        Clears all items in the multimap
      • contains

        default boolean contains​(Object key,
                                 Object value)
        Checks if the given key and value exist in the multimap
        Parameters:
        key - the key
        value - the value
        Returns:
        True if the key is mapped to value, false otherwise
      • containsKey

        default boolean containsKey​(Object key)
        Checks if the key is contained in the multimap
        Parameters:
        key - the key
        Returns:
        True if the key is mapped to one or more values in the multimap
      • containsValue

        default boolean containsValue​(Object value)
        Checks if the value exists in the multimap
        Parameters:
        value - the value
        Returns:
        True if there exists a key that is mapped to the value, false otherwise
      • entries

        default Set<Map.Entry<K,​V>> entries()
        A set of the entries in the multimap
        Returns:
        the set of key-value pairs in the multimap
      • get

        Collection<V> get​(Object key)
        Gets the values mapped to by the given key. A new collection is created if the key does not exist in the multimap.
        Parameters:
        key - the key
        Returns:
        the collection of values.
      • isEmpty

        default boolean isEmpty()
        Checks if the multimap is empty, i.e. has no valid mappings.
        Returns:
        True if it is empty
      • keySet

        default Set<K> keySet()
        Gets the set of keys in the multimap
        Returns:
        the set of keys in the multimap
      • put

        default boolean put​(K key,
                            V value)
        Puts the key-value pair mapping in the multimap
        Parameters:
        key - the key
        value - the value
        Returns:
        true if the key-value pair was successfully added.
      • putAll

        default void putAll​(@NonNull
                            @NonNull Map<? extends K,​? extends Collection<? extends V>> map)
        Put all key-value pairs in the multimap
        Parameters:
        map - the map of key value pairs to add
      • putAll

        default void putAll​(@NonNull
                            @NonNull Multimap<? extends K,​? extends V> multimap)
        Put all key-value pairs in the multimap
        Parameters:
        multimap - the map of key value pairs to add
      • putAll

        default void putAll​(K key,
                            Iterable<? extends V> values)
        Puts all values for a given key
        Parameters:
        key - the key
        values - the values
      • remove

        default boolean remove​(Object key,
                               Object value)
        Removes the given key-value pair from the multimap
        Parameters:
        key - the key
        value - the value
        Returns:
        true the key-value pair was successfully removed
      • removeAll

        Collection<V> removeAll​(Object key)
        Removes all values for the given key.
        Parameters:
        key - the key
        Returns:
        the collection of values associated with the key
      • replace

        void replace​(K key,
                     Iterable<? extends V> values)
        Replaces the values for a given key with the given new values
        Parameters:
        key - the key
        values - the values
      • size

        default int size()
        The number of key-value mappings in the multimap
        Returns:
        the number of key-value mappings
      • values

        default Collection<V> values()
        Provides a view of the values in the multimap
        Returns:
        the collection