From e773fb78b4e415cf28b12a4721fa02989e97f048 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 3 Jan 2020 09:29:18 +0100 Subject: [PATCH] MoreCollectors should declare it returns ImmutableSet/List --- .../java/org/sonar/core/util/stream/MoreCollectors.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java index 9bf7efd5284..83a763b177b 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java +++ b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java @@ -55,7 +55,7 @@ public final class MoreCollectors { /** * A Collector into an {@link ImmutableList}. */ - public static Collector, List> toList() { + public static Collector, ImmutableList> toList() { return Collector.of( ArrayList::new, List::add, @@ -72,7 +72,7 @@ public final class MoreCollectors { *

Note: using this method with a parallel stream will likely not have the expected memory usage benefit as all * processing threads will use a List with a capacity large enough for the final size.

*/ - public static Collector, List> toList(int expectedSize) { + public static Collector, ImmutableList> toList(int expectedSize) { // use ArrayList rather than ImmutableList.Builder because initial capacity of builder can not be specified return Collector.of( () -> new ArrayList<>(expectedSize), @@ -87,7 +87,7 @@ public final class MoreCollectors { /** * A Collector into an {@link ImmutableSet}. */ - public static Collector, Set> toSet() { + public static Collector, ImmutableSet> toSet() { return Collector.of( HashSet::new, Set::add, @@ -104,7 +104,7 @@ public final class MoreCollectors { *

Note: using this method with a parallel stream will likely not have the expected memory usage benefit as all * processing threads will use a Set with a capacity large enough for the final size.

*/ - public static Collector, Set> toSet(int expectedSize) { + public static Collector, ImmutableSet> toSet(int expectedSize) { // use HashSet rather than ImmutableSet.Builder because initial capacity of builder can not be specified return Collector.of( () -> new HashSet<>(expectedSize), -- 2.39.5