From a29be33ac7b1d3e97cccd3593abc4c16394d77c0 Mon Sep 17 00:00:00 2001 From: Andreas Stadelmeier Date: Tue, 31 Dec 2024 18:03:01 +0100 Subject: [PATCH] Remove more wildcards in Collector --- .../classes/java/util/stream/Collectors.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/java.base/share/classes/java/util/stream/Collectors.java b/src/java.base/share/classes/java/util/stream/Collectors.java index a4b70b83041..2d896e58fec 100644 --- a/src/java.base/share/classes/java/util/stream/Collectors.java +++ b/src/java.base/share/classes/java/util/stream/Collectors.java @@ -523,7 +523,7 @@ public final class Collectors { * @since 9 */ public static - Collector filtering(Predicate predicate, + Collector filtering(Predicate predicate, Collector downstream) { BiConsumer downstreamAccumulator = downstream.accumulator(); return new CollectorImpl<>(downstream.supplier(), @@ -588,7 +588,7 @@ public final class Collectors { * @param the type of the input elements * @return a {@code Collector} that counts the input elements */ - public static Collector + public static Collector counting() { return summingLong(e -> 1L); } @@ -640,7 +640,7 @@ public final class Collectors { * @param mapper a function extracting the property to be summed * @return a {@code Collector} that produces the sum of a derived property */ - public static Collector + public static Collector summingInt(ToIntFunction mapper) { return new CollectorImpl<>( () -> new int[1], @@ -658,7 +658,7 @@ public final class Collectors { * @param mapper a function extracting the property to be summed * @return a {@code Collector} that produces the sum of a derived property */ - public static Collector + public static Collector summingLong(ToLongFunction mapper) { return new CollectorImpl<>( () -> new long[1], @@ -683,7 +683,7 @@ public final class Collectors { * @param mapper a function extracting the property to be summed * @return a {@code Collector} that produces the sum of a derived property */ - public static Collector + public static Collector summingDouble(ToDoubleFunction mapper) { /* * In the arrays allocated for the collect operation, index 0 @@ -751,7 +751,7 @@ public final class Collectors { * @return a {@code Collector} that produces the arithmetic mean of a * derived property */ - public static Collector + public static Collector averagingInt(ToIntFunction mapper) { return new CollectorImpl<>( () -> new long[2], @@ -770,7 +770,7 @@ public final class Collectors { * @return a {@code Collector} that produces the arithmetic mean of a * derived property */ - public static Collector + public static Collector averagingLong(ToLongFunction mapper) { return new CollectorImpl<>( () -> new long[2], @@ -802,7 +802,7 @@ public final class Collectors { * @return a {@code Collector} that produces the arithmetic mean of a * derived property */ - public static Collector + public static Collector averagingDouble(ToDoubleFunction mapper) { /* * In the arrays allocated for the collect operation, index 0 @@ -844,7 +844,7 @@ public final class Collectors { * @see #reducing(BinaryOperator) * @see #reducing(Object, Function, BinaryOperator) */ - public static Collector + public static Collector reducing(T identity, BinaryOperator op) { return new CollectorImpl<>( boxSupplier(identity), @@ -998,7 +998,7 @@ public final class Collectors { * @see #groupingBy(Function, Supplier, Collector) * @see #groupingByConcurrent(Function) */ - public static Collector>> + public static Collector>, Map>> groupingBy(Function classifier) { return groupingBy(classifier, toList()); } @@ -1048,7 +1048,7 @@ public final class Collectors { * @see #groupingByConcurrent(Function, Collector) */ public static - Collector> groupingBy(Function classifier, + Collector, Map> groupingBy(Function classifier, Collector downstream) { return groupingBy(classifier, HashMap::new, downstream); } @@ -1165,7 +1165,7 @@ public final class Collectors { * @see #groupingByConcurrent(Function, Supplier, Collector) */ public static - Collector>> + Collector>, ConcurrentMap>> groupingByConcurrent(Function classifier) { return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList()); } @@ -1211,7 +1211,7 @@ public final class Collectors { * @see #groupingByConcurrent(Function, Supplier, Collector) */ public static - Collector> groupingByConcurrent(Function classifier, + Collector, ConcurrentMap> groupingByConcurrent(Function classifier, Collector downstream) { return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream); } @@ -1475,7 +1475,7 @@ public final class Collectors { */ @SuppressWarnings({"rawtypes", "unchecked"}) public static - Collector> toUnmodifiableMap(Function keyMapper, + Collector, Map> toUnmodifiableMap(Function keyMapper, Function valueMapper) { Objects.requireNonNull(keyMapper, "keyMapper"); Objects.requireNonNull(valueMapper, "valueMapper"); @@ -1541,7 +1541,7 @@ public final class Collectors { * @see #toConcurrentMap(Function, Function, BinaryOperator) */ public static - Collector> toMap(Function keyMapper, + Collector, Map> toMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction) { return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new); @@ -1581,7 +1581,7 @@ public final class Collectors { */ @SuppressWarnings({"rawtypes", "unchecked"}) public static - Collector> toUnmodifiableMap(Function keyMapper, + Collector, Map> toUnmodifiableMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction) { Objects.requireNonNull(keyMapper, "keyMapper"); @@ -1633,7 +1633,7 @@ public final class Collectors { * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) */ public static > - Collector toMap(Function keyMapper, + Collector toMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction, Supplier mapFactory) { @@ -1696,7 +1696,7 @@ public final class Collectors { * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) */ public static - Collector> toConcurrentMap(Function keyMapper, + Collector, ConcurrentMap> toConcurrentMap(Function keyMapper, Function valueMapper) { return new CollectorImpl<>(ConcurrentHashMap::new, uniqKeysMapAccumulator(keyMapper, valueMapper), @@ -1797,7 +1797,7 @@ public final class Collectors { * @see #toMap(Function, Function, BinaryOperator, Supplier) */ public static > - Collector toConcurrentMap(Function keyMapper, + Collector toConcurrentMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction, Supplier mapFactory) { @@ -1820,7 +1820,7 @@ public final class Collectors { * @see #summarizingLong(ToLongFunction) */ public static - Collector summarizingInt(ToIntFunction mapper) { + Collector summarizingInt(ToIntFunction mapper) { return new CollectorImpl<>( IntSummaryStatistics::new, (r, t) -> r.accept(mapper.applyAsInt(t)), @@ -1843,7 +1843,7 @@ public final class Collectors { * @see #summarizingInt(ToIntFunction) */ public static - Collector summarizingLong(ToLongFunction mapper) { + Collector summarizingLong(ToLongFunction mapper) { return new CollectorImpl<>( LongSummaryStatistics::new, (r, t) -> r.accept(mapper.applyAsLong(t)), @@ -1866,7 +1866,7 @@ public final class Collectors { * @see #summarizingInt(ToIntFunction) */ public static - Collector summarizingDouble(ToDoubleFunction mapper) { + Collector summarizingDouble(ToDoubleFunction mapper) { return new CollectorImpl<>( DoubleSummaryStatistics::new, (r, t) -> r.accept(mapper.applyAsDouble(t)),