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) {
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||||
parentResult.entrySet().forEach(entry -> {
|
|
||||||
String beanName = entry.getKey();
|
parentResult.forEach((beanName, beanType) -> {
|
||||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
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) {
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||||
|
|
||||||
parentResult.entrySet().forEach(entry -> {
|
parentResult.forEach((beanName, beanType) -> {
|
||||||
String beanName = entry.getKey();
|
|
||||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
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()) {
|
if (!this.customEditors.isEmpty()) {
|
||||||
this.customEditors.entrySet().forEach(entry -> {
|
this.customEditors.forEach(
|
||||||
Class<?> requiredType = entry.getKey();
|
(requiredType, editorClass)
|
||||||
Class<? extends PropertyEditor> editorClass = entry.getValue();
|
-> registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass))
|
||||||
registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass));
|
);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class BindingAwareConcurrentModel extends ConcurrentModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ?> map) {
|
public void putAll(Map<? extends String, ?> map) {
|
||||||
map.entrySet().forEach(e -> removeBindingResultIfNecessary(e.getKey(), e.getValue()));
|
map.forEach(this::removeBindingResultIfNecessary);
|
||||||
super.putAll(map);
|
super.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
|
||||||
*/
|
*/
|
||||||
public LinkedMultiValueMap<K, V> deepCopy() {
|
public LinkedMultiValueMap<K, V> deepCopy() {
|
||||||
LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.targetMap.size());
|
LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.targetMap.size());
|
||||||
this.targetMap.entrySet().forEach(entry ->
|
this.targetMap.forEach((k, v) -> copy.put(k, new LinkedList<>(v)));
|
||||||
copy.put(entry.getKey(), new LinkedList<>(entry.getValue())));
|
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -194,9 +194,9 @@ public abstract class UriUtils {
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> encodeUriVariables(Map<String, ?> uriVariables) {
|
public static Map<String, String> encodeUriVariables(Map<String, ?> uriVariables) {
|
||||||
Map<String, String> result = new LinkedHashMap<>(uriVariables.size());
|
Map<String, String> result = new LinkedHashMap<>(uriVariables.size());
|
||||||
uriVariables.entrySet().stream().forEach(entry -> {
|
uriVariables.forEach((key, value) -> {
|
||||||
String stringValue = (entry.getValue() != null ? entry.getValue().toString() : "");
|
String stringValue = (value != null ? value.toString() : "");
|
||||||
result.put(entry.getKey(), encode(stringValue, StandardCharsets.UTF_8));
|
result.put(key, encode(stringValue, StandardCharsets.UTF_8));
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,10 +175,11 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder {
|
||||||
|
|
||||||
MultiValueMap<String, HttpCookie> requestCookies = request.getCookies();
|
MultiValueMap<String, HttpCookie> requestCookies = request.getCookies();
|
||||||
if (!this.cookies.isEmpty()) {
|
if (!this.cookies.isEmpty()) {
|
||||||
this.cookies.forEach((name, values) -> values.forEach(value -> {
|
this.cookies.forEach(( name , values) ->
|
||||||
HttpCookie cookie = new HttpCookie(name, value);
|
values.forEach(value -> {
|
||||||
requestCookies.add(name, cookie);
|
HttpCookie cookie = new HttpCookie(name, value);
|
||||||
}));
|
requestCookies.add(name, cookie);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.inserter.insert(request, new BodyInserter.Context() {
|
return this.inserter.insert(request, new BodyInserter.Context() {
|
||||||
|
|
|
||||||
|
|
@ -224,10 +224,10 @@ class ControllerMethodResolver {
|
||||||
Class<?> handlerType = handlerMethod.getBeanType();
|
Class<?> handlerType = handlerMethod.getBeanType();
|
||||||
|
|
||||||
// Global methods first
|
// Global methods first
|
||||||
this.initBinderAdviceCache.entrySet().forEach(entry -> {
|
this.initBinderAdviceCache.forEach((adviceBean, methods) -> {
|
||||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
if (adviceBean.isApplicableToBeanType(handlerType)) {
|
||||||
Object bean = entry.getKey().resolveBean();
|
Object bean = adviceBean.resolveBean();
|
||||||
entry.getValue().forEach(method -> result.add(getInitBinderMethod(bean, method)));
|
methods.forEach(method -> result.add(getInitBinderMethod(bean, method)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -257,10 +257,10 @@ class ControllerMethodResolver {
|
||||||
Class<?> handlerType = handlerMethod.getBeanType();
|
Class<?> handlerType = handlerMethod.getBeanType();
|
||||||
|
|
||||||
// Global methods first
|
// Global methods first
|
||||||
this.modelAttributeAdviceCache.entrySet().forEach(entry -> {
|
this.modelAttributeAdviceCache.forEach((adviceBean, methods) -> {
|
||||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
if (adviceBean.isApplicableToBeanType(handlerType)) {
|
||||||
Object bean = entry.getKey().resolveBean();
|
Object bean = adviceBean.resolveBean();
|
||||||
entry.getValue().forEach(method -> result.add(createAttributeMethod(bean, method)));
|
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) {
|
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) {
|
private HttpHeaders toHttpHeaders(HttpClientResponse response) {
|
||||||
|
|
|
||||||
|
|
@ -281,8 +281,8 @@ public class BaseViewTests {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
private void checkContainsAll(Map expected, Map<String, Object> actual) {
|
private void checkContainsAll(Map expected, Map<String, Object> actual) {
|
||||||
expected.keySet().stream().forEach(
|
expected.forEach(
|
||||||
key -> assertEquals("Values for model key '" + key + "' must match", expected.get(key), actual.get(key))
|
(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);
|
view.render(model, request, response);
|
||||||
assertEquals(url, response.getForwardedUrl());
|
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);
|
view.render(model, request, response);
|
||||||
assertEquals(url, response.getIncludedUrl());
|
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
|
@Test
|
||||||
|
|
@ -116,7 +117,7 @@ public class InternalResourceViewTests {
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
assertEquals(url, response.getIncludedUrl());
|
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
|
@Test
|
||||||
|
|
@ -132,7 +133,7 @@ public class InternalResourceViewTests {
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
assertEquals(url, response.getIncludedUrl());
|
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