Make ImmutableMap Stream collect()ion nicer (#654)

This adds an entriesToImmutableMap() collector that can be used in place of
toImmutableMap(Map.Entry::getkey, Map.Entry::getValue()).

It also fixes up some existing calls that use toImmutableMap() when terser
alternatives exist.
This commit is contained in:
Ben McIlwain 2020-06-26 11:57:26 -04:00 committed by GitHub
parent fba6804d3b
commit 74b2de5c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 49 additions and 54 deletions

View file

@ -29,6 +29,7 @@ import google.registry.gradle.plugin.ProjectData.TaskData;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -162,7 +163,7 @@ final class CoverPageGenerator {
task.reports().entrySet().stream()
.collect(
toImmutableMap(
entry -> entry.getKey(),
Map.Entry::getKey,
entry ->
entry.getValue().files().isEmpty()
? ""

View file

@ -168,7 +168,7 @@ final class GcsPluginUtils {
.collect(
toImmutableMap(
file -> rootDir.relativize(toNormalizedPath(file)),
file -> toByteArraySupplier(file)));
GcsPluginUtils::toByteArraySupplier));
if (files.isEmpty()) {
// The directory exists, but is empty. Return empty FilesWithEntryPoint