From bc4d7d1bc93c6187335b1cc7ac62a7ad0a81dcc4 Mon Sep 17 00:00:00 2001 From: Andreas Stadelmeier Date: Tue, 17 Dec 2024 20:39:01 +0100 Subject: [PATCH] Remove further wildcards from Collectors --- .../classes/java/util/stream/Collectors.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 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 76a7a24ebc7..a4b70b83041 100644 --- a/src/java.base/share/classes/java/util/stream/Collectors.java +++ b/src/java.base/share/classes/java/util/stream/Collectors.java @@ -245,24 +245,6 @@ public final class Collectors { CH_ID); } - - /** - * Returns a {@code Collector} that accumulates the input elements into a - * new {@code List}. There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code List} returned; if more - * control over the returned {@code List} is required, use {@link #toCollection(Supplier)}. - * - * @param the type of the input elements - * @return a {@code Collector} which collects all the input elements into a - * {@code List}, in encounter order - */ - public static - Collector, List> toList2() { - return new CollectorImpl<>(ArrayList::new, List::add, - (left, right) -> { left.addAll(right); return left; }, - CH_ID); - } - /** * Returns a {@code Collector} that accumulates the input elements into an * unmodifiable List in encounter @@ -922,9 +904,8 @@ public final class Collectors { } } } - return new CollectorImpl<>( - OptionalBox::new, OptionalBox::accept, + OptionalBox::new, Consumer::accept, (a, b) -> { if (b.present) a.accept(b.value); return a; @@ -970,7 +951,7 @@ public final class Collectors { * @see #reducing(BinaryOperator) */ public static - Collector reducing(U identity, + Collector reducing(U identity, Function mapper, BinaryOperator op) { return new CollectorImpl<>(