Merge pull request #1449 from diguage:dev
* pr/1449: Polish "Use Map#forEach instead of Map#entrySet#forEach" Use Map#forEach instead of Map#entrySet#forEach
This commit is contained in:
@@ -265,10 +265,9 @@ 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 +313,9 @@ 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,11 +1187,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -281,9 +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)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -84,9 +84,8 @@ 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)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +100,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 +115,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 +131,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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user