Class LinkedMultiValueMap<K,​V>

  • All Implemented Interfaces:
    MultiValueMap<K,​V>, java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​java.util.List<V>>

    public class LinkedMultiValueMap<K,​V>
    extends java.util.LinkedHashMap<K,​java.util.List<V>>
    implements MultiValueMap<K,​V>, java.io.Serializable

    This class is a clone of org.springframework.util.LinkedMultiValueMap

    Simple implementation of MultiValueMap that wraps a LinkedHashMap, storing multiple values in a LinkedList.

    This Map implementation is generally not thread-safe. It is primarily designed for data structures exposed from request objects, for use in a single thread only.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      LinkedMultiValueMap()
      Create a new LinkedMultiValueMap that wraps a LinkedHashMap.
      LinkedMultiValueMap​(int initialCapacity)
      Create a new LinkedMultiValueMap that wraps a LinkedHashMap with the given initial capacity.
      LinkedMultiValueMap​(java.util.Map<K,​java.util.List<V>> otherMap)
      Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(K key, V value)
      Add the given single value to the current list of values for the given key.
      LinkedMultiValueMap<K,​V> clone()
      Create a regular copy of this Map.
      LinkedMultiValueMap<K,​V> deepCopy()
      Create a deep copy of this Map.
      V getFirst​(K key)
      Return the first value for the given key.
      void put​(K key, V[] values)
      Set the given values under the given key.
      void set​(K key, V value)
      Set the given single value under the given key.
      void setAll​(java.util.Map<K,​V> values)
      Set the given values under.
      java.util.Map<K,​V> toSingleValueMap()
      Returns the first values contained in this MultiValueMap.
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from class java.util.HashMap

        compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Constructor Detail

      • LinkedMultiValueMap

        public LinkedMultiValueMap()
        Create a new LinkedMultiValueMap that wraps a LinkedHashMap.
      • LinkedMultiValueMap

        public LinkedMultiValueMap​(int initialCapacity)
        Create a new LinkedMultiValueMap that wraps a LinkedHashMap with the given initial capacity.
        Parameters:
        initialCapacity - the initial capacity
      • LinkedMultiValueMap

        public LinkedMultiValueMap​(java.util.Map<K,​java.util.List<V>> otherMap)
        Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map. Note that this will be a shallow copy; its value-holding List entries will get reused and therefore cannot get modified independently.
        Parameters:
        otherMap - the Map whose mappings are to be placed in this Map
        See Also:
        clone(), deepCopy()
    • Method Detail

      • add

        public void add​(K key,
                        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
      • getFirst

        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
      • set

        public void set​(K key,
                        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​(java.util.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
      • put

        public void put​(K key,
                        V[] values)
        Description copied from interface: MultiValueMap
        Set the given values under the given key.
        Specified by:
        put in interface MultiValueMap<K,​V>
        Parameters:
        key - the key
        values - the values
      • toSingleValueMap

        public java.util.Map<K,​V> toSingleValueMap()
        Description copied from interface: MultiValueMap
        Returns the first values contained in this MultiValueMap.
        Specified by:
        toSingleValueMap in interface MultiValueMap<K,​V>
        Returns:
        a single value representation of this map
      • clone

        public LinkedMultiValueMap<K,​V> clone()
        Create a regular copy of this Map.
        Overrides:
        clone in class java.util.HashMap<K,​java.util.List<V>>
        Returns:
        a shallow copy of this Map, reusing this Map's value-holding List entries
        See Also:
        LinkedMultiValueMap(Map), deepCopy()
      • deepCopy

        public LinkedMultiValueMap<K,​V> deepCopy()
        Create a deep copy of this Map.
        Returns:
        a copy of this Map, including a copy of each value-holding List entry
        See Also:
        clone()