Polish "Use Java 8 forEach method on Map"
Closes gh-1404
This commit is contained in:
@@ -106,10 +106,10 @@ public abstract class ClassUtils {
|
||||
primitiveWrapperTypeMap.put(Integer.class, int.class);
|
||||
primitiveWrapperTypeMap.put(Long.class, long.class);
|
||||
primitiveWrapperTypeMap.put(Short.class, short.class);
|
||||
|
||||
primitiveWrapperTypeMap.entrySet().forEach(entry -> {
|
||||
primitiveTypeToWrapperMap.put(entry.getValue(), entry.getKey());
|
||||
registerCommonClasses(entry.getKey());
|
||||
|
||||
primitiveWrapperTypeMap.forEach((key, value) -> {
|
||||
primitiveTypeToWrapperMap.put(value, key);
|
||||
registerCommonClasses(key);
|
||||
});
|
||||
|
||||
Set<Class<?>> primitiveTypes = new HashSet<>(32);
|
||||
|
||||
@@ -354,9 +354,9 @@ public abstract class CollectionUtils {
|
||||
public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
|
||||
Assert.notNull(map, "'map' must not be null");
|
||||
Map<K, List<V>> result = new LinkedHashMap<>(map.size());
|
||||
map.entrySet().forEach(entry -> {
|
||||
List<? extends V> values = Collections.unmodifiableList(entry.getValue());
|
||||
result.put(entry.getKey(), (List<V>) values);
|
||||
map.forEach((key, value) -> {
|
||||
List<? extends V> values = Collections.unmodifiableList(value);
|
||||
result.put(key, (List<V>) values);
|
||||
});
|
||||
Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
|
||||
return toMultiValueMap(unmodifiableMap);
|
||||
@@ -431,13 +431,13 @@ public abstract class CollectionUtils {
|
||||
|
||||
@Override
|
||||
public void setAll(Map<K, V> values) {
|
||||
values.entrySet().forEach(entry -> set(entry.getKey(), entry.getValue()));
|
||||
values.forEach(this::set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<>(this.map.size());
|
||||
map.entrySet().forEach(entry -> singleValueMap.put(entry.getKey(), entry.getValue().get(0)));
|
||||
this.map.forEach((key, value) -> singleValueMap.put(key, value.get(0)));
|
||||
return singleValueMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,8 +169,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
map.entrySet().forEach(entry -> put(entry.getKey(), entry.getValue()));
|
||||
|
||||
map.forEach(this::put);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,14 +100,13 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
|
||||
|
||||
@Override
|
||||
public void setAll(Map<K, V> values) {
|
||||
values.entrySet().forEach(entry -> set(entry.getKey(), entry.getValue()));
|
||||
values.forEach(this::set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<>(this.targetMap.size());
|
||||
this.targetMap.entrySet().forEach(entry ->
|
||||
singleValueMap.put(entry.getKey(), entry.getValue().get(0)));
|
||||
this.targetMap.forEach((key, value) -> singleValueMap.put(key, value.get(0)));
|
||||
|
||||
return singleValueMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user