mirror of
https://github.com/google/nomulus
synced 2026-01-05 13:07:04 +00:00
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:
@@ -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()
|
||||
? ""
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user