Polish "Use lambdas for map entry iteration where possible"
Closes gh-12626
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user