Use Map#forEach instead of Map#entrySet#forEach
See gh-1449
This commit is contained in:
parent
424bc75fb1
commit
2efa06237a
|
|
@ -265,10 +265,10 @@ public abstract class BeanFactoryUtils {
|
|||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
parentResult.entrySet().forEach(entry -> {
|
||||
String beanName = entry.getKey();
|
||||
|
||||
parentResult.forEach((beanName, beanType) -> {
|
||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
result.put(beanName, entry.getValue());
|
||||
result.put(beanName, beanType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -314,11 +314,10 @@ public abstract class BeanFactoryUtils {
|
|||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
|
||||
parentResult.entrySet().forEach(entry -> {
|
||||
String beanName = entry.getKey();
|
||||
|
||||
parentResult.forEach((beanName, beanType) -> {
|
||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
result.put(beanName, entry.getValue());
|
||||
result.put(beanName, beanType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1187,12 +1187,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||
}
|
||||
}
|
||||
if (!this.customEditors.isEmpty()) {
|
||||
this.customEditors.entrySet().forEach(entry -> {
|
||||
Class<?> requiredType = entry.getKey();
|
||||
Class<? extends PropertyEditor> editorClass = entry.getValue();
|
||||
registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass));
|
||||
});
|
||||
}
|
||||
this.customEditors.forEach(
|
||||
(requiredType, editorClass)
|
||||
-> registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class BindingAwareConcurrentModel extends ConcurrentModel {
|
|||
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ?> map) {
|
||||
map.entrySet().forEach(e -> removeBindingResultIfNecessary(e.getKey(), e.getValue()));
|
||||
map.forEach(this::removeBindingResultIfNecessary);
|
||||
super.putAll(map);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -195,8 +195,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
|
|||
*/
|
||||
public LinkedMultiValueMap<K, V> deepCopy() {
|
||||
LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.targetMap.size());
|
||||
this.targetMap.entrySet().forEach(entry ->
|
||||
copy.put(entry.getKey(), new LinkedList<>(entry.getValue())));
|
||||
this.targetMap.forEach((k, v) -> copy.put(k, new LinkedList<>(v)));
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,9 +194,9 @@ public abstract class UriUtils {
|
|||
*/
|
||||
public static Map<String, String> encodeUriVariables(Map<String, ?> uriVariables) {
|
||||
Map<String, String> result = new LinkedHashMap<>(uriVariables.size());
|
||||
uriVariables.entrySet().stream().forEach(entry -> {
|
||||
String stringValue = (entry.getValue() != null ? entry.getValue().toString() : "");
|
||||
result.put(entry.getKey(), encode(stringValue, StandardCharsets.UTF_8));
|
||||
uriVariables.forEach((key, value) -> {
|
||||
String stringValue = (value != null ? value.toString() : "");
|
||||
result.put(key, encode(stringValue, StandardCharsets.UTF_8));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,10 +175,11 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder {
|
|||
|
||||
MultiValueMap<String, HttpCookie> requestCookies = request.getCookies();
|
||||
if (!this.cookies.isEmpty()) {
|
||||
this.cookies.forEach((name, values) -> values.forEach(value -> {
|
||||
HttpCookie cookie = new HttpCookie(name, value);
|
||||
requestCookies.add(name, cookie);
|
||||
}));
|
||||
this.cookies.forEach(( name , values) ->
|
||||
values.forEach(value -> {
|
||||
HttpCookie cookie = new HttpCookie(name, value);
|
||||
requestCookies.add(name, cookie);
|
||||
}));
|
||||
}
|
||||
|
||||
return this.inserter.insert(request, new BodyInserter.Context() {
|
||||
|
|
|
|||
|
|
@ -224,10 +224,10 @@ class ControllerMethodResolver {
|
|||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
|
||||
// Global methods first
|
||||
this.initBinderAdviceCache.entrySet().forEach(entry -> {
|
||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
||||
Object bean = entry.getKey().resolveBean();
|
||||
entry.getValue().forEach(method -> result.add(getInitBinderMethod(bean, method)));
|
||||
this.initBinderAdviceCache.forEach((adviceBean, methods) -> {
|
||||
if (adviceBean.isApplicableToBeanType(handlerType)) {
|
||||
Object bean = adviceBean.resolveBean();
|
||||
methods.forEach(method -> result.add(getInitBinderMethod(bean, method)));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -257,10 +257,10 @@ class ControllerMethodResolver {
|
|||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
|
||||
// Global methods first
|
||||
this.modelAttributeAdviceCache.entrySet().forEach(entry -> {
|
||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
||||
Object bean = entry.getKey().resolveBean();
|
||||
entry.getValue().forEach(method -> result.add(createAttributeMethod(bean, method)));
|
||||
this.modelAttributeAdviceCache.forEach((adviceBean, methods) -> {
|
||||
if (adviceBean.isApplicableToBeanType(handlerType)) {
|
||||
Object bean = adviceBean.resolveBean();
|
||||
methods.forEach(method -> result.add(createAttributeMethod(bean, method)));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class ReactorNettyWebSocketClient extends WebSocketClientSupport implemen
|
|||
}
|
||||
|
||||
private void setNettyHeaders(HttpHeaders headers, io.netty.handler.codec.http.HttpHeaders nettyHeaders) {
|
||||
headers.keySet().stream().forEach(key -> nettyHeaders.set(key, headers.get(key)));
|
||||
headers.forEach(nettyHeaders::set);
|
||||
}
|
||||
|
||||
private HttpHeaders toHttpHeaders(HttpClientResponse response) {
|
||||
|
|
|
|||
|
|
@ -281,8 +281,8 @@ public class BaseViewTests {
|
|||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private void checkContainsAll(Map expected, Map<String, Object> actual) {
|
||||
expected.keySet().stream().forEach(
|
||||
key -> assertEquals("Values for model key '" + key + "' must match", expected.get(key), actual.get(key))
|
||||
expected.forEach(
|
||||
(k, v) -> assertEquals("Values for model key '" + k + "' must match", expected.get(k), actual.get(k))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,9 @@ public class InternalResourceViewTests {
|
|||
view.render(model, request, response);
|
||||
assertEquals(url, response.getForwardedUrl());
|
||||
|
||||
model.keySet().stream().forEach(
|
||||
key -> assertEquals("Values for model key '" + key + "' must match", model.get(key), request.getAttribute(key))
|
||||
|
||||
model.forEach(
|
||||
(key, value) -> assertEquals("Values for model key '" + key + "' must match", value, request.getAttribute(key))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ public class InternalResourceViewTests {
|
|||
view.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
|
||||
model.keySet().stream().forEach(key -> verify(request).setAttribute(key, model.get(key)));
|
||||
model.forEach((key, value) -> verify(request).setAttribute(key, value));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -116,7 +117,7 @@ public class InternalResourceViewTests {
|
|||
view.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
|
||||
model.keySet().stream().forEach(key -> verify(request).setAttribute(key, model.get(key)));
|
||||
model.forEach((key, value) -> verify(request).setAttribute(key, value));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -132,7 +133,7 @@ public class InternalResourceViewTests {
|
|||
view.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
|
||||
model.keySet().stream().forEach(key -> verify(request).setAttribute(key, model.get(key)));
|
||||
model.forEach((k, v) -> verify(request).setAttribute(k, v));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue