Browse Source

Polish "Use Map#forEach instead of Map#entrySet#forEach"

Closes gh-1449
pull/1454/merge
Stephane Nicoll 8 years ago
parent
commit
451b419624
  1. 2
      spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java
  2. 8
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  3. 9
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java
  4. 7
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java
  5. 8
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java

2
spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java

@ -265,7 +265,6 @@ public abstract class BeanFactoryUtils { @@ -265,7 +265,6 @@ public abstract class BeanFactoryUtils {
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
parentResult.forEach((beanName, beanType) -> {
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
result.put(beanName, beanType);
@ -314,7 +313,6 @@ public abstract class BeanFactoryUtils { @@ -314,7 +313,6 @@ public abstract class BeanFactoryUtils {
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
parentResult.forEach((beanName, beanType) -> {
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
result.put(beanName, beanType);

8
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

@ -1187,11 +1187,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1187,11 +1187,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
}
if (!this.customEditors.isEmpty()) {
this.customEditors.forEach(
(requiredType, editorClass)
-> registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass))
);
}
this.customEditors.forEach((requiredType, editorClass) ->
registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass)));
}
}

9
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java

@ -175,11 +175,10 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @@ -175,11 +175,10 @@ 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() {

7
spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -281,9 +281,8 @@ public class BaseViewTests {
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void checkContainsAll(Map expected, Map<String, Object> actual) {
expected.forEach(
(k, v) -> assertEquals("Values for model key '" + k + "' must match", expected.get(k), actual.get(k))
);
expected.forEach((k, v) -> assertEquals("Values for model key '" + k
+ "' must match", expected.get(k), actual.get(k)));
}

8
spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java

@ -1,5 +1,5 @@ @@ -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,10 +84,8 @@ public class InternalResourceViewTests { @@ -84,10 +84,8 @@ public class InternalResourceViewTests {
view.render(model, request, response);
assertEquals(url, response.getForwardedUrl());
model.forEach(
(key, value) -> assertEquals("Values for model key '" + key + "' must match", value, request.getAttribute(key))
);
model.forEach((key, value) -> assertEquals("Values for model key '" + key
+ "' must match", value, request.getAttribute(key)));
}
@Test

Loading…
Cancel
Save