diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index edadd3ab909..bc147c1ab44 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -335,9 +335,10 @@ public abstract class CollectionUtils { } /** - * Adapt a {@code Map>} to an {@code MultiValueMap}. - * @param map the map + * Adapt a {@code Map>} to an {@code MultiValueMap}. + * @param map the original map * @return the multi-value map + * @since 3.1 */ public static MultiValueMap toMultiValueMap(Map> map) { return new MultiValueMapAdapter(map); @@ -348,13 +349,15 @@ public abstract class CollectionUtils { * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. + * @since 3.1 */ - public static MultiValueMap unmodifiableMultiValueMap(MultiValueMap map) { + @SuppressWarnings("unchecked") + public static MultiValueMap unmodifiableMultiValueMap(MultiValueMap map) { Assert.notNull(map, "'map' must not be null"); Map> result = new LinkedHashMap>(map.size()); for (Map.Entry> entry : map.entrySet()) { - List values = Collections.unmodifiableList(entry.getValue()); - result.put(entry.getKey(), values); + List values = Collections.unmodifiableList(entry.getValue()); + result.put(entry.getKey(), (List) values); } Map> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); @@ -366,7 +369,7 @@ public abstract class CollectionUtils { */ private static class EnumerationIterator implements Iterator { - private Enumeration enumeration; + private final Enumeration enumeration; public EnumerationIterator(Enumeration enumeration) { this.enumeration = enumeration; @@ -476,8 +479,8 @@ public abstract class CollectionUtils { } @Override - public void putAll(Map> m) { - this.map.putAll(m); + public void putAll(Map> map) { + this.map.putAll(map); } @Override