Use lambdas for map entry iteration where possible

See gh-12626
This commit is contained in:
igor-suhorukov
2018-03-24 09:19:03 +03:00
committed by Phillip Webb
parent 78a94cafe1
commit 69bc19e0ca
31 changed files with 125 additions and 232 deletions

View File

@@ -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) {