K
- the key typeV
- the value element typepublic class LinkedMultiValueMap<K,V> extends java.lang.Object implements MultiValueMap<K,V>, java.io.Serializable, java.lang.Cloneable
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.
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V value)
Add the given single value to the current list of values for the given key.
|
void |
addAll(K key,
java.util.List<? extends V> values)
Add all the values of the given list to the current list of values for the given key.
|
void |
addAll(MultiValueMap<K,V> values)
Add all the values of the given
MultiValueMap to the current values. |
void |
clear() |
LinkedMultiValueMap<K,V> |
clone()
Create a regular copy of this Map.
|
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
LinkedMultiValueMap<K,V> |
deepCopy()
Create a deep copy of this Map.
|
java.util.Set<java.util.Map.Entry<K,java.util.List<V>>> |
entrySet() |
boolean |
equals(java.lang.Object obj) |
java.util.List<V> |
get(java.lang.Object key) |
V |
getFirst(K key)
Return the first value for the given key.
|
int |
hashCode() |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
java.util.List<V> |
put(K key,
java.util.List<V> value) |
void |
putAll(java.util.Map<? extends K,? extends java.util.List<V>> map) |
java.util.List<V> |
remove(java.lang.Object 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.
|
int |
size() |
java.util.Map<K,V> |
toSingleValueMap()
Return a
Map with the first values contained in this MultiValueMap . |
java.lang.String |
toString() |
java.util.Collection<java.util.List<V>> |
values() |
public LinkedMultiValueMap()
LinkedHashMap
.public LinkedMultiValueMap(int initialCapacity)
LinkedHashMap
with the given initial capacity.initialCapacity
- the initial capacitypublic LinkedMultiValueMap(java.util.Map<K,java.util.List<V>> otherMap)
otherMap
- the Map whose mappings are to be placed in this Mapclone()
,
deepCopy()
@Nullable public V getFirst(K key)
MultiValueMap
getFirst
in interface MultiValueMap<K,V>
key
- the keynull
if nonepublic void add(K key, @Nullable V value)
MultiValueMap
add
in interface MultiValueMap<K,V>
key
- the keyvalue
- the value to be addedpublic void addAll(K key, java.util.List<? extends V> values)
MultiValueMap
addAll
in interface MultiValueMap<K,V>
key
- they keyvalues
- the values to be addedpublic void addAll(MultiValueMap<K,V> values)
MultiValueMap
MultiValueMap
to the current values.addAll
in interface MultiValueMap<K,V>
values
- the values to be addedpublic void set(K key, @Nullable V value)
MultiValueMap
set
in interface MultiValueMap<K,V>
key
- the keyvalue
- the value to setpublic void setAll(java.util.Map<K,V> values)
MultiValueMap
setAll
in interface MultiValueMap<K,V>
values
- the values.public java.util.Map<K,V> toSingleValueMap()
MultiValueMap
Map
with the first values contained in this MultiValueMap
.toSingleValueMap
in interface MultiValueMap<K,V>
public boolean isEmpty()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public java.util.Set<K> keySet()
public java.util.Collection<java.util.List<V>> values()
public LinkedMultiValueMap<K,V> deepCopy()
LinkedList
for each entry)
along the lines of MultiValueMap.addAll
semanticsaddAll(MultiValueMap)
,
clone()
public LinkedMultiValueMap<K,V> clone()
clone
in class java.lang.Object
Map.put
semanticsput(Object, List)
,
putAll(Map)
,
LinkedMultiValueMap(Map)
,
deepCopy()
public boolean equals(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
toString
in class java.lang.Object