Class MultiValueMapAdapter<K,V>

java.lang.Object
org.springframework.util.MultiValueMapAdapter<K,V>
Type Parameters:
K - the key type
V - the value element type
All Implemented Interfaces:
Serializable, Map<K,List<V>>, MultiValueMap<K,V>
Direct Known Subclasses:
LinkedMultiValueMap

public class MultiValueMapAdapter<K,V> extends Object implements MultiValueMap<K,V>, Serializable
Adapts a given Map to the MultiValueMap contract.
Since:
5.3
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
  • Constructor Details Link icon

    • MultiValueMapAdapter Link icon

      public MultiValueMapAdapter(Map<K,List<V>> targetMap)
      Wrap the given target Map as a MultiValueMap adapter.
      Parameters:
      targetMap - the plain target Map
  • Method Details Link icon

    • getFirst Link icon

      public @Nullable V getFirst(K key)
      Description copied from interface: MultiValueMap
      Return the first value for the given key.
      Specified by:
      getFirst in interface MultiValueMap<K,V>
      Parameters:
      key - the key
      Returns:
      the first value for the specified key, or null if none
    • add Link icon

      public void add(K key, @Nullable V value)
      Description copied from interface: MultiValueMap
      Add the given single value to the current list of values for the given key.
      Specified by:
      add in interface MultiValueMap<K,V>
      Parameters:
      key - the key
      value - the value to be added
    • addAll Link icon

      public void addAll(K key, List<? extends V> values)
      Description copied from interface: MultiValueMap
      Add all the values of the given list to the current list of values for the given key.
      Specified by:
      addAll in interface MultiValueMap<K,V>
      Parameters:
      key - they key
      values - the values to be added
    • addAll Link icon

      public void addAll(MultiValueMap<K,V> values)
      Description copied from interface: MultiValueMap
      Add all the values of the given MultiValueMap to the current values.
      Specified by:
      addAll in interface MultiValueMap<K,V>
      Parameters:
      values - the values to be added
    • set Link icon

      public void set(K key, @Nullable V value)
      Description copied from interface: MultiValueMap
      Set the given single value under the given key.
      Specified by:
      set in interface MultiValueMap<K,V>
      Parameters:
      key - the key
      value - the value to set
    • setAll Link icon

      public void setAll(Map<K,V> values)
      Description copied from interface: MultiValueMap
      Set the given values under.
      Specified by:
      setAll in interface MultiValueMap<K,V>
      Parameters:
      values - the values.
    • toSingleValueMap Link icon

      public Map<K,V> toSingleValueMap()
      Description copied from interface: MultiValueMap
      Return a Map with the first values contained in this MultiValueMap. The difference between this method and MultiValueMap.asSingleValueMap() is that this method returns a copy of the entries of this map, whereas the latter returns a view.
      Specified by:
      toSingleValueMap in interface MultiValueMap<K,V>
      Returns:
      a single value representation of this map
    • size Link icon

      public int size()
      Specified by:
      size in interface Map<K,V>
    • isEmpty Link icon

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey Link icon

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue Link icon

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • get Link icon

      public @Nullable List<V> get(Object key)
      Specified by:
      get in interface Map<K,V>
    • put Link icon

      public @Nullable List<V> put(K key, List<V> value)
      Specified by:
      put in interface Map<K,V>
    • putIfAbsent Link icon

      public @Nullable List<V> putIfAbsent(K key, List<V> value)
      Specified by:
      putIfAbsent in interface Map<K,V>
    • remove Link icon

      public @Nullable List<V> remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • putAll Link icon

      public void putAll(Map<? extends K, ? extends List<V>> map)
      Specified by:
      putAll in interface Map<K,V>
    • clear Link icon

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • keySet Link icon

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values Link icon

      public Collection<List<V>> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet Link icon

      public Set<Map.Entry<K,List<V>>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • forEach Link icon

      public void forEach(BiConsumer<? super K, ? super List<V>> action)
      Specified by:
      forEach in interface Map<K,V>
    • equals Link icon

      public boolean equals(@Nullable Object other)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object