Make MultiValueMapAdapter public (as base class for LinkedMultiValueMap)
Closes gh-25960
This commit is contained in:
parent
a2ff03074f
commit
a3f3a136c4
|
@ -457,7 +457,6 @@ public abstract class CollectionUtils {
|
|||
* @since 3.1
|
||||
*/
|
||||
public static <K, V> MultiValueMap<K, V> toMultiValueMap(Map<K, List<V>> targetMap) {
|
||||
Assert.notNull(targetMap, "'targetMap' must not be null");
|
||||
return new MultiValueMapAdapter<>(targetMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ import java.util.Map;
|
|||
* @param <K> the key type
|
||||
* @param <V> the value element type
|
||||
*/
|
||||
public class LinkedMultiValueMap<K, V> extends MultiValueMapAdapter<K, V> implements Serializable, Cloneable {
|
||||
public class LinkedMultiValueMap<K, V> extends MultiValueMapAdapter<K, V> // new public base class in 5.3
|
||||
implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 3801124242820219131L;
|
||||
|
||||
|
|
|
@ -30,23 +30,30 @@ import org.springframework.lang.Nullable;
|
|||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
* @since 5.3
|
||||
* @param <K> the key type
|
||||
* @param <V> the value element type
|
||||
* @see CollectionUtils#toMultiValueMap
|
||||
* @see LinkedMultiValueMap
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
|
||||
public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
|
||||
|
||||
private final Map<K, List<V>> targetMap;
|
||||
|
||||
|
||||
MultiValueMapAdapter(Map<K, List<V>> targetMap) {
|
||||
/**
|
||||
* Wrap the given target {@link Map} as a {@link MultiValueMap} adapter.
|
||||
* @param targetMap the plain target {@code Map}
|
||||
*/
|
||||
public MultiValueMapAdapter(Map<K, List<V>> targetMap) {
|
||||
Assert.notNull(targetMap, "'targetMap' must not be null");
|
||||
this.targetMap = targetMap;
|
||||
}
|
||||
|
||||
|
||||
// MultiValueMap implementation
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V getFirst(K key) {
|
||||
|
@ -96,6 +103,9 @@ class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
|
|||
return singleValueMap;
|
||||
}
|
||||
|
||||
|
||||
// Map implementation
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.targetMap.size();
|
||||
|
|
Loading…
Reference in New Issue