Skip to content

Commit

Permalink
Make MultiValueMapAdapter public (as base class for LinkedMultiValueMap)
Browse files Browse the repository at this point in the history
Closes gh-25960
  • Loading branch information
jhoeller committed Oct 26, 2020
1 parent a2ff030 commit a3f3a13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Expand Up @@ -457,7 +457,6 @@ public static <E> Iterator<E> toIterator(@Nullable Enumeration<E> enumeration) {
* @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);
}

Expand Down
Expand Up @@ -35,7 +35,8 @@
* @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;

Expand Down
Expand Up @@ -30,23 +30,30 @@
*
* @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) {
Expand Down Expand Up @@ -96,6 +103,9 @@ public Map<K, V> toSingleValueMap() {
return singleValueMap;
}


// Map implementation

@Override
public int size() {
return this.targetMap.size();
Expand Down

0 comments on commit a3f3a13

Please sign in to comment.