org.springframework.util
Class LinkedMultiValueMap<K,V>

java.lang.Object
  extended by org.springframework.util.LinkedMultiValueMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,List<V>>, MultiValueMap<K,V>

public class LinkedMultiValueMap<K,V>
extends Object
implements MultiValueMap<K,V>, Serializable

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.

Since:
3.0
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
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(Map<K,List<V>> otherMap)
          Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map.
 
Method Summary
 void add(K key, V value)
          Add the given single value to the current list of values for the given key.
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,List<V>>> entrySet()
           
 boolean equals(Object obj)
           
 List<V> get(Object key)
           
 V getFirst(K key)
          Return the first value for the given key.
 int hashCode()
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 List<V> put(K key, List<V> value)
           
 void putAll(Map<? extends K,? extends List<V>> m)
           
 List<V> remove(Object key)
           
 void set(K key, V value)
          Set the given single value under the given key.
 void setAll(Map<K,V> values)
          Set the given values under.
 int size()
           
 Map<K,V> toSingleValueMap()
          Returns the first values contained in this MultiValueMap.
 String toString()
           
 Collection<List<V>> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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(Map<K,List<V>> otherMap)
Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map.

Parameters:
otherMap - the Map whose mappings are to be placed in this Map
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(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
Returns the first values contained in this MultiValueMap.

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,List<V>>

isEmpty

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

containsKey

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

containsValue

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

get

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

put

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

remove

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

putAll

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

clear

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

keySet

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

values

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

entrySet

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

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map<K,List<V>>
Overrides:
equals in class Object

hashCode

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

toString

public String toString()
Overrides:
toString in class Object