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

    • MultiValueMapAdapter

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

    • getFirst

      @Nullable public 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

      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

      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

      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

      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

      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

      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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public String toString()
      Overrides:
      toString in class Object