Package com.aspectran.utils
Class LinkedMultiValueMap<K,V>
java.lang.Object
com.aspectran.utils.LinkedMultiValueMap<K,V>
- Type Parameters:
K
- the key typeV
- the value element type
- All Implemented Interfaces:
MultiValueMap<K,
,V> Serializable
,Cloneable
,Map<K,
List<V>>
public class LinkedMultiValueMap<K,V>
extends Object
implements MultiValueMap<K,V>, Serializable, Cloneable
This class is a clone of org.springframework.util.LinkedMultiValueMap
Simple implementation ofMultiValueMap
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:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new LinkedMultiValueMap that wraps aLinkedHashMap
.LinkedMultiValueMap
(int initialCapacity) Create a new LinkedMultiValueMap that wraps aLinkedHashMap
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
Modifier and TypeMethodDescriptionvoid
Add the given single value to the current list of values for the given key.void
addAll
(MultiValueMap<K, V> values) Add all the values of the givenMultiValueMap
to the current values.void
Add all the values of the given list to the current list of values for the given key.void
clear()
clone()
Create a regular copy of this Map.boolean
containsKey
(Object key) boolean
containsValue
(Object value) deepCopy()
Create a deep copy of this Map.entrySet()
boolean
Return the first value for the given key.int
hashCode()
boolean
isEmpty()
keySet()
void
void
Set the given single value under the given key.void
Set the given values under the given key.void
Set the given values under.int
size()
Return aMap
with the first values contained in thisMultiValueMap
.toString()
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
Methods inherited from interface com.aspectran.utils.MultiValueMap
addIfAbsent
-
Constructor Details
-
LinkedMultiValueMap
public LinkedMultiValueMap()Create a new LinkedMultiValueMap that wraps aLinkedHashMap
. -
LinkedMultiValueMap
public LinkedMultiValueMap(int initialCapacity) Create a new LinkedMultiValueMap that wraps aLinkedHashMap
with the given initial capacity.- Parameters:
initialCapacity
- the initial capacity
-
LinkedMultiValueMap
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:
-
-
Method Details
-
getFirst
Description copied from interface:MultiValueMap
Return the first value for the given key.- Specified by:
getFirst
in interfaceMultiValueMap<K,
V> - Parameters:
key
- the key- Returns:
- the first value for the specified key, or
null
if none
-
add
Description copied from interface:MultiValueMap
Add the given single value to the current list of values for the given key.- Specified by:
add
in interfaceMultiValueMap<K,
V> - Parameters:
key
- the keyvalue
- the value to be added
-
addAll
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 interfaceMultiValueMap<K,
V> - Parameters:
key
- they keyvalues
- the values to be added
-
addAll
Description copied from interface:MultiValueMap
Add all the values of the givenMultiValueMap
to the current values.- Specified by:
addAll
in interfaceMultiValueMap<K,
V> - Parameters:
values
- the values to be added
-
set
Description copied from interface:MultiValueMap
Set the given single value under the given key.- Specified by:
set
in interfaceMultiValueMap<K,
V> - Parameters:
key
- the keyvalue
- the value to set
-
set
Description copied from interface:MultiValueMap
Set the given values under the given key.- Specified by:
set
in interfaceMultiValueMap<K,
V> - Parameters:
key
- the keyvalues
- the values
-
toSingleValueMap
Description copied from interface:MultiValueMap
Return aMap
with the first values contained in thisMultiValueMap
.- Specified by:
toSingleValueMap
in interfaceMultiValueMap<K,
V> - Returns:
- a single value representation of this map
-
setAll
Description copied from interface:MultiValueMap
Set the given values under.- Specified by:
setAll
in interfaceMultiValueMap<K,
V> - Parameters:
values
- the values
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
deepCopy
Create a deep copy of this Map.- Returns:
- a copy of this Map, including a copy of each value-holding List entry
(consistently using an independent modifiable
LinkedList
for each entry) along the lines ofMultiValueMap.addAll
semantics - See Also:
-
clone
Create a regular copy of this Map. -
equals
-
hashCode
public int hashCode() -
toString
-