mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +02: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:
parent
fba6804d3b
commit
74b2de5c35
15 changed files with 49 additions and 54 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue