Use Java 8 forEach method on Map
This commit is contained in:
parent
1ea54eb2c6
commit
13dc0cd828
|
@ -264,12 +264,12 @@ public abstract class BeanFactoryUtils {
|
|||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
for (Map.Entry<String, T> entry : parentResult.entrySet()) {
|
||||
parentResult.entrySet().forEach(entry -> {
|
||||
String beanName = entry.getKey();
|
||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
result.put(beanName, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -313,12 +313,13 @@ public abstract class BeanFactoryUtils {
|
|||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
for (Map.Entry<String, T> entry : parentResult.entrySet()) {
|
||||
|
||||
parentResult.entrySet().forEach(entry -> {
|
||||
String beanName = entry.getKey();
|
||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
result.put(beanName, entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -1177,11 +1177,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||
}
|
||||
}
|
||||
if (!this.customEditors.isEmpty()) {
|
||||
for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
|
||||
this.customEditors.entrySet().forEach(entry -> {
|
||||
Class<?> requiredType = entry.getKey();
|
||||
Class<? extends PropertyEditor> editorClass = entry.getValue();
|
||||
registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,11 +106,11 @@ public abstract class ClassUtils {
|
|||
primitiveWrapperTypeMap.put(Integer.class, int.class);
|
||||
primitiveWrapperTypeMap.put(Long.class, long.class);
|
||||
primitiveWrapperTypeMap.put(Short.class, short.class);
|
||||
|
||||
for (Map.Entry<Class<?>, Class<?>> entry : primitiveWrapperTypeMap.entrySet()) {
|
||||
|
||||
primitiveWrapperTypeMap.entrySet().forEach(entry -> {
|
||||
primitiveTypeToWrapperMap.put(entry.getValue(), entry.getKey());
|
||||
registerCommonClasses(entry.getKey());
|
||||
}
|
||||
});
|
||||
|
||||
Set<Class<?>> primitiveTypes = new HashSet<>(32);
|
||||
primitiveTypes.addAll(primitiveWrapperTypeMap.values());
|
||||
|
|
|
@ -354,10 +354,10 @@ 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());
|
||||
for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) {
|
||||
map.entrySet().forEach(entry -> {
|
||||
List<? extends V> values = Collections.unmodifiableList(entry.getValue());
|
||||
result.put(entry.getKey(), (List<V>) values);
|
||||
}
|
||||
});
|
||||
Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
|
||||
return toMultiValueMap(unmodifiableMap);
|
||||
}
|
||||
|
@ -431,17 +431,13 @@ public abstract class CollectionUtils {
|
|||
|
||||
@Override
|
||||
public void setAll(Map<K, V> values) {
|
||||
for (Entry<K, V> entry : values.entrySet()) {
|
||||
set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.entrySet().forEach(entry -> set(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<>(this.map.size());
|
||||
for (Entry<K, List<V>> entry : map.entrySet()) {
|
||||
singleValueMap.put(entry.getKey(), entry.getValue().get(0));
|
||||
}
|
||||
map.entrySet().forEach(entry -> singleValueMap.put(entry.getKey(), entry.getValue().get(0)));
|
||||
return singleValueMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,9 +169,8 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
|||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<? extends String, ? extends V> entry : map.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
map.entrySet().forEach(entry -> put(entry.getKey(), entry.getValue()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,17 +100,15 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
|
|||
|
||||
@Override
|
||||
public void setAll(Map<K, V> values) {
|
||||
for (Entry<K, V> entry : values.entrySet()) {
|
||||
set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.entrySet().forEach(entry -> set(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<>(this.targetMap.size());
|
||||
for (Entry<K, List<V>> entry : this.targetMap.entrySet()) {
|
||||
singleValueMap.put(entry.getKey(), entry.getValue().get(0));
|
||||
}
|
||||
this.targetMap.entrySet().forEach(entry ->
|
||||
singleValueMap.put(entry.getKey(), entry.getValue().get(0)));
|
||||
|
||||
return singleValueMap;
|
||||
}
|
||||
|
||||
|
@ -186,9 +184,9 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
|
|||
*/
|
||||
public LinkedMultiValueMap<K, V> deepCopy() {
|
||||
LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.targetMap.size());
|
||||
for (Map.Entry<K, List<V>> entry : this.targetMap.entrySet()) {
|
||||
copy.put(entry.getKey(), new LinkedList<>(entry.getValue()));
|
||||
}
|
||||
this.targetMap.entrySet().forEach(entry ->
|
||||
copy.put(entry.getKey(), new LinkedList<>(entry.getValue())));
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,11 +192,12 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(methods.size() + " request handler methods found on " + userType + ": " + methods);
|
||||
}
|
||||
for (Map.Entry<Method, T> entry : methods.entrySet()) {
|
||||
|
||||
methods.entrySet().forEach(entry -> {
|
||||
Method invocableMethod = AopUtils.selectInvocableMethod(entry.getKey(), userType);
|
||||
T mapping = entry.getValue();
|
||||
registerHandlerMethod(handler, invocableMethod, mapping);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,7 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
|
|||
logger.warn("Neither 'urlMap' nor 'mappings' set on SimpleUrlHandlerMapping");
|
||||
}
|
||||
else {
|
||||
for (Map.Entry<String, Object> entry : urlMap.entrySet()) {
|
||||
urlMap.entrySet().forEach(entry -> {
|
||||
String url = entry.getKey();
|
||||
Object handler = entry.getValue();
|
||||
// Prepend with slash if not already present.
|
||||
|
@ -126,7 +126,7 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
|
|||
handler = ((String) handler).trim();
|
||||
}
|
||||
registerHandler(url, handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue