Polish "Use lambdas for map entry iteration where possible"

Closes gh-12626
This commit is contained in:
Phillip Webb
2018-04-04 19:35:41 -07:00
parent 69bc19e0ca
commit 685babc829
27 changed files with 209 additions and 176 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@@ -58,18 +58,17 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
}
@Override
public void processResource(String resource, InputStream is,
public void processResource(String resource, InputStream inputStream,
List<Relocator> relocators) throws IOException {
Properties properties = new Properties();
properties.load(is);
is.close();
properties.forEach((key, valueObject) -> {
String name = (String) key;
String value = (String) valueObject;
String existing = this.data.getProperty(name);
this.data.setProperty(name,
existing == null ? value : existing + "," + value);
});
properties.load(inputStream);
inputStream.close();
properties.forEach((name, value) -> process((String) name, (String) value));
}
private void process(String name, String value) {
String existing = this.data.getProperty(name);
this.data.setProperty(name, (existing == null ? value : existing + "," + value));
}
@Override

View File

@@ -140,10 +140,11 @@ public final class Verify {
}
private ZipEntry getEntryStartingWith(String entryName) {
return this.content.entrySet().stream().
filter(entry -> entry.getKey().startsWith(entryName)).
map(Map.Entry::getValue).findFirst().orElseThrow(() ->
new IllegalStateException("Unable to find entry starting with " + entryName));
return this.content.entrySet().stream()
.filter(entry -> entry.getKey().startsWith(entryName))
.map(Map.Entry::getValue).findFirst()
.orElseThrow(() -> new IllegalStateException(
"Unable to find entry starting with " + entryName));
}
public boolean hasEntry(String entry) {