Use Map.forEach instead of manual Map.Entry iteration wherever possible
Issue: SPR-16646
This commit is contained in:
@@ -466,9 +466,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
this.customEditors.forEach(target::registerCustomEditor);
|
||||
}
|
||||
if (this.customEditorsForPath != null) {
|
||||
for (Map.Entry<String, CustomEditorHolder> entry : this.customEditorsForPath.entrySet()) {
|
||||
String editorPath = entry.getKey();
|
||||
CustomEditorHolder editorHolder = entry.getValue();
|
||||
this.customEditorsForPath.forEach((editorPath, editorHolder) -> {
|
||||
if (nestedProperty != null) {
|
||||
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(editorPath);
|
||||
if (pos != -1) {
|
||||
@@ -484,7 +482,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
target.registerCustomEditor(
|
||||
editorHolder.getRegisteredType(), editorPath, editorHolder.getPropertyEditor());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -97,9 +97,7 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (this.scopes != null) {
|
||||
for (Map.Entry<String, Object> entry : this.scopes.entrySet()) {
|
||||
String scopeKey = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
this.scopes.forEach((scopeKey, value) -> {
|
||||
if (value instanceof Scope) {
|
||||
beanFactory.registerScope(scopeKey, (Scope) value);
|
||||
}
|
||||
@@ -118,7 +116,7 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
|
||||
scopeKey + "] is not an instance of required type [" + Scope.class.getName() +
|
||||
"] or a corresponding Class or String value indicating a Scope implementation");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -25,7 +25,6 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -272,8 +271,7 @@ public abstract class YamlProcessor {
|
||||
}
|
||||
|
||||
private void buildFlattenedMap(Map<String, Object> result, Map<String, Object> source, @Nullable String path) {
|
||||
for (Entry<String, Object> entry : source.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
source.forEach((key, value) -> {
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (key.startsWith("[")) {
|
||||
key = path + key;
|
||||
@@ -282,7 +280,6 @@ public abstract class YamlProcessor {
|
||||
key = path + '.' + key;
|
||||
}
|
||||
}
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
result.put(key, value);
|
||||
}
|
||||
@@ -305,7 +302,7 @@ public abstract class YamlProcessor {
|
||||
else {
|
||||
result.put(key, (value != null ? value : ""));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -421,12 +421,11 @@ class BeanDefinitionValueResolver {
|
||||
*/
|
||||
private Map<?, ?> resolveManagedMap(Object argName, Map<?, ?> mm) {
|
||||
Map<Object, Object> resolved = new LinkedHashMap<>(mm.size());
|
||||
for (Map.Entry<?, ?> entry : mm.entrySet()) {
|
||||
Object resolvedKey = resolveValueIfNecessary(argName, entry.getKey());
|
||||
Object resolvedValue = resolveValueIfNecessary(
|
||||
new KeyedArgName(argName, entry.getKey()), entry.getValue());
|
||||
mm.forEach((key, value) -> {
|
||||
Object resolvedKey = resolveValueIfNecessary(argName, key);
|
||||
Object resolvedValue = resolveValueIfNecessary(new KeyedArgName(argName, key), value);
|
||||
resolved.put(resolvedKey, resolvedValue);
|
||||
}
|
||||
});
|
||||
return resolved;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user