Class LinkedMultiValueMap<K,V>
- java.lang.Object
-
- org.hotswap.agent.util.spring.collections.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 ofMultiValueMapthat wraps aLinkedHashMap, storing multiple values in aLinkedList.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
-
-
Constructor Summary
Constructors Constructor Description LinkedMultiValueMap()Create a new LinkedMultiValueMap that wraps aLinkedHashMap.LinkedMultiValueMap(int initialCapacity)Create a new LinkedMultiValueMap that wraps aLinkedHashMapwith 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(K key, V value)Add the given single value to the current list of values for the given key.voidclear()LinkedMultiValueMap<K,V>clone()Create a regular copy of this Map.booleancontainsKey(Object key)booleancontainsValue(Object value)LinkedMultiValueMap<K,V>deepCopy()Create a deep copy of this Map.Set<Map.Entry<K,List<V>>>entrySet()booleanequals(Object obj)List<V>get(Object key)VgetFirst(K key)Return the first value for the given key.inthashCode()booleanisEmpty()Set<K>keySet()List<V>put(K key, List<V> value)voidputAll(Map<? extends K,? extends List<V>> map)List<V>remove(Object key)voidset(K key, V value)Set the given single value under the given key.voidsetAll(Map<K,V> values)Set the given values under.intsize()Map<K,V>toSingleValueMap()Returns the first values contained in thisMultiValueMap.StringtoString()Collection<List<V>>values()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
LinkedMultiValueMap
public LinkedMultiValueMap()
Create a new LinkedMultiValueMap that wraps aLinkedHashMap.
-
LinkedMultiValueMap
public LinkedMultiValueMap(int initialCapacity)
Create a new LinkedMultiValueMap that wraps aLinkedHashMapwith 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. 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:MultiValueMapAdd the given single value to the current list of values for the given key.- Specified by:
addin interfaceMultiValueMap<K,V>- Parameters:
key- the keyvalue- the value to be added
-
getFirst
public V getFirst(K key)
Description copied from interface:MultiValueMapReturn the first value for the given key.- Specified by:
getFirstin interfaceMultiValueMap<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:MultiValueMapSet the given single value under the given key.- Specified by:
setin interfaceMultiValueMap<K,V>- Parameters:
key- the keyvalue- the value to set
-
setAll
public void setAll(Map<K,V> values)
Description copied from interface:MultiValueMapSet the given values under.- Specified by:
setAllin interfaceMultiValueMap<K,V>- Parameters:
values- the values.
-
toSingleValueMap
public Map<K,V> toSingleValueMap()
Description copied from interface:MultiValueMapReturns the first values contained in thisMultiValueMap.- Specified by:
toSingleValueMapin interfaceMultiValueMap<K,V>- Returns:
- a single value representation of this map
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
clone
public LinkedMultiValueMap<K,V> clone()
Create a regular copy of this Map.- Overrides:
clonein classObject- Returns:
- a shallow copy of this Map, reusing this Map's value-holding List entries
- Since:
- 4.2
- 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
- Since:
- 4.2
- See Also:
clone()
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
-