Skip to content

Commit 78534a7

Browse files
committed
Polish "Iterate map by using lambda function"
See gh-12528
1 parent ffc883b commit 78534a7

File tree

9 files changed

+26
-25
lines changed

9 files changed

+26
-25
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public abstract class AbstractHealthAggregator implements HealthAggregator {
3434
@Override
3535
public final Health aggregate(Map<String, Health> healths) {
3636
List<Status> statusCandidates = new ArrayList<>();
37-
healths.values().forEach(health -> statusCandidates.add(health.getStatus()));
37+
healths.values().forEach((health) -> statusCandidates.add(health.getStatus()));
3838
Status status = aggregateStatus(statusCandidates);
3939
Map<String, Object> details = aggregateDetails(healths);
4040
return new Health.Builder(status, details).build();

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -196,39 +196,39 @@ private void extractPropertiesFromServices(Properties properties,
196196

197197
@SuppressWarnings("unchecked")
198198
private void flatten(Properties properties, Map<String, Object> input, String path) {
199-
input.forEach((entryKey, value) -> {
200-
String key = getFullKey(path, entryKey);
199+
input.forEach((key, value) -> {
200+
String name = getPropertyName(path, key);
201201
if (value instanceof Map) {
202202
// Need a compound key
203-
flatten(properties, (Map<String, Object>) value, key);
203+
flatten(properties, (Map<String, Object>) value, name);
204204
}
205205
else if (value instanceof Collection) {
206206
// Need a compound key
207207
Collection<Object> collection = (Collection<Object>) value;
208-
properties.put(key,
208+
properties.put(name,
209209
StringUtils.collectionToCommaDelimitedString(collection));
210210
int count = 0;
211211
for (Object item : collection) {
212212
String itemKey = "[" + (count++) + "]";
213-
flatten(properties, Collections.singletonMap(itemKey, item), key);
213+
flatten(properties, Collections.singletonMap(itemKey, item), name);
214214
}
215215
}
216216
else if (value instanceof String) {
217-
properties.put(key, value);
217+
properties.put(name, value);
218218
}
219219
else if (value instanceof Number) {
220-
properties.put(key, value.toString());
220+
properties.put(name, value.toString());
221221
}
222222
else if (value instanceof Boolean) {
223-
properties.put(key, value.toString());
223+
properties.put(name, value.toString());
224224
}
225225
else {
226-
properties.put(key, value == null ? "" : value);
226+
properties.put(name, value == null ? "" : value);
227227
}
228228
});
229229
}
230230

231-
private String getFullKey(String path, String key) {
231+
private String getPropertyName(String path, String key) {
232232
if (!StringUtils.hasText(path)) {
233233
return key;
234234
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ private boolean isNegative(Duration sessionTimeout) {
246246
}
247247

248248
private void addLocaleMappings(WebAppContext context) {
249-
getLocaleCharsetMappings().forEach((locale, charset) ->
250-
context.addLocaleEncoding(locale.toString(), charset.toString()));
249+
getLocaleCharsetMappings().forEach((locale, charset) -> context
250+
.addLocaleEncoding(locale.toString(), charset.toString()));
251251
}
252252

253253
private File getTempDirectory() {

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ private void resetDefaultLocaleMapping(TomcatEmbeddedContext context) {
232232
}
233233

234234
private void addLocaleMappings(TomcatEmbeddedContext context) {
235-
getLocaleCharsetMappings().forEach((locale, charset) ->
236-
context.addLocaleEncodingMappingParameter(locale.toString(), charset.toString()));
235+
getLocaleCharsetMappings()
236+
.forEach((locale, charset) -> context.addLocaleEncodingMappingParameter(
237+
locale.toString(), charset.toString()));
237238
}
238239

239240
private void configureTldSkipPatterns(TomcatEmbeddedContext context) {

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,8 +69,8 @@ private void save(Map<String, PersistentSession> sessionData, File file)
6969
private void save(Map<String, PersistentSession> sessionData,
7070
ObjectOutputStream stream) throws IOException {
7171
Map<String, Serializable> session = new LinkedHashMap<>();
72-
sessionData.forEach((key, value) ->
73-
session.put(key, new SerializablePersistentSession(value)));
72+
sessionData.forEach((key, value) -> session.put(key,
73+
new SerializablePersistentSession(value)));
7474
stream.writeObject(session);
7575
}
7676

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ private XnioWorker createWorker() throws IOException {
328328
}
329329

330330
private void addLocaleMappings(DeploymentInfo deployment) {
331-
getLocaleCharsetMappings().forEach((locale, charset) ->
332-
deployment.addLocaleCharsetMapping(locale.toString(), charset.toString()));
331+
getLocaleCharsetMappings().forEach((locale, charset) -> deployment
332+
.addLocaleCharsetMapping(locale.toString(), charset.toString()));
333333
}
334334

335335
private void registerServletContainerInitializerToDriveServletContextInitializers(

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public ServletContextInitializerBeans(ListableBeanFactory beanFactory) {
7979
addServletContextInitializerBeans(beanFactory);
8080
addAdaptableBeans(beanFactory);
8181
List<ServletContextInitializer> sortedInitializers = new ArrayList<>();
82-
this.initializers.values().forEach(contextInitializers -> {
82+
this.initializers.values().forEach((contextInitializers) -> {
8383
AnnotationAwareOrderComparator.sort(contextInitializers);
8484
sortedInitializers.addAll(contextInitializers);
8585
});

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)