Interface SetValuedMap<K,V>

Type Parameters:
K - the type of the keys in this map
V - the type of the values in this map
All Superinterfaces:
MultiValuedMap<K,V>
All Known Implementing Classes:
AbstractSetValuedMap, HashSetValuedHashMap, LinkedHashSetValuedLinkedHashMap

public interface SetValuedMap<K,V> extends MultiValuedMap<K,V>
Defines a map that holds a set of values against each key.

A SetValuedMap is a Map with slightly different semantics:

  • Putting a value into the map will add the value to a Set at that key.
  • Getting a value will return a Set, holding all the values put to that key.
Since:
4.1
  • Method Details

    • get

      Set<V> get(K key)
      Gets the set of values associated with the specified key.

      Implementations typically return an empty Set if no values have been mapped to the key.

      Specified by:
      get in interface MultiValuedMap<K,V>
      Parameters:
      key - the key to retrieve
      Returns:
      the Set of values, implementations should return an empty Set for no mapping
      Throws:
      NullPointerException - if the key is null and null keys are invalid
    • remove

      Set<V> remove(Object key)
      Removes all values associated with the specified key.

      The returned set may be modifiable, but updates will not be propagated to this set-valued map. In case no mapping was stored for the specified key, an empty, unmodifiable set will be returned.

      Specified by:
      remove in interface MultiValuedMap<K,V>
      Parameters:
      key - the key to remove values from
      Returns:
      the Set of values removed, implementations should return null for no mapping found, but may return an empty collection
      Throws:
      UnsupportedOperationException - if the map is unmodifiable
      NullPointerException - if the key is null and null keys are invalid