Use lambdas for map entry iteration where possible
See gh-12626
This commit is contained in:
committed by
Phillip Webb
parent
78a94cafe1
commit
69bc19e0ca
@@ -19,7 +19,6 @@ package org.springframework.boot.maven;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@@ -64,13 +63,13 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
|
||||
Properties properties = new Properties();
|
||||
properties.load(is);
|
||||
is.close();
|
||||
for (Entry<Object, Object> entry : properties.entrySet()) {
|
||||
String name = (String) entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -140,13 +140,10 @@ public final class Verify {
|
||||
}
|
||||
|
||||
private ZipEntry getEntryStartingWith(String entryName) {
|
||||
for (Map.Entry<String, ZipEntry> entry : this.content.entrySet()) {
|
||||
if (entry.getKey().startsWith(entryName)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
throw 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) {
|
||||
|
||||
Reference in New Issue
Block a user