Package org.springframework.util

# Class LinkedMultiValueMap<K,V>

java.lang.Object
org.springframework.util.MultiValueMapAdapter<K,V>
org.springframework.util.LinkedMultiValueMap<K,V>

Type Parameters:
  `K` - the key type
  `V` - the value element type

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Map<K,List<V>>`, `MultiValueMap<K,V>`

public class LinkedMultiValueMap<K,V> extends MultiValueMapAdapter<K,V> implements Serializable, Cloneable
Simple implementation of `MultiValueMap` that wraps a `LinkedHashMap`, storing multiple values in an `ArrayList`.

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 extends Object,V extends Object>`

## Constructor Summary

Constructors
Constructor
Description
`LinkedMultiValueMap()`
Create a new LinkedMultiValueMap that wraps a `LinkedHashMap`.
`LinkedMultiValueMap(int expectedSize)`
Create a new LinkedMultiValueMap that wraps a `LinkedHashMap` with an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.
`LinkedMultiValueMap(Map<K,List<V>> otherMap)`
Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map.

## Method Summary

Modifier and Type
Method
Description
`LinkedMultiValueMap<K,V>`
`clone()`
Create a regular copy of this Map.
`LinkedMultiValueMap<K,V>`
`deepCopy()`
Create a deep copy of this Map.

### Methods inherited from class org.springframework.util.MultiValueMapAdapter

`add, addAll, addAll, clear, containsKey, containsValue, entrySet, equals, forEach, get, getFirst, hashCode, isEmpty, keySet, put, putAll, putIfAbsent, remove, set, setAll, size, toSingleValueMap, toString, 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, getOrDefault, merge, remove, replace, replace, replaceAll`

### Methods inherited from interface org.springframework.util.MultiValueMap

`addIfAbsent, asSingleValueMap`

## Constructor Details

### LinkedMultiValueMap

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

### LinkedMultiValueMap

public LinkedMultiValueMap(int expectedSize)
Create a new LinkedMultiValueMap that wraps a `LinkedHashMap` with an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.

Parameters:
  `expectedSize` - the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)
See Also:
  - `CollectionUtils.newLinkedHashMap(int)`

### 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 Details

### 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 (consistently using an independent modifiable `ArrayList` for each entry) along the lines of `MultiValueMap.addAll` semantics
Since:
  4.2
See Also:
  - `MultiValueMapAdapter.addAll(MultiValueMap)`
  - `clone()`

### clone

public LinkedMultiValueMap<K,V> clone()
Create a regular copy of this Map.

Overrides:
  `clone` in class `Object`
Returns:
  a shallow copy of this Map, reusing this Map's value-holding List entries (even if some entries are shared or unmodifiable) along the lines of standard `Map.put` semantics
Since:
  4.2
See Also:
  - `MultiValueMapAdapter.put(Object, List)`
  - `MultiValueMapAdapter.putAll(Map)`
  - `LinkedMultiValueMap(Map)`
  - `deepCopy()`