Skip to content

Commit af00880

Browse files
altrisiPaul Hohensee
authored and
Paul Hohensee
committed
8284640: CollectorImpl class could be a record class
Reviewed-by: phh, rriggs
1 parent c67149b commit af00880

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

src/java.base/share/classes/java/util/stream/Collectors.java

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -194,56 +194,19 @@ private static <I, R> Function<I, R> castingIdentity() {
194194
* @param <T> the type of elements to be collected
195195
* @param <R> the type of the result
196196
*/
197-
static class CollectorImpl<T, A, R> implements Collector<T, A, R> {
198-
private final Supplier<A> supplier;
199-
private final BiConsumer<A, T> accumulator;
200-
private final BinaryOperator<A> combiner;
201-
private final Function<A, R> finisher;
202-
private final Set<Characteristics> characteristics;
203-
204-
CollectorImpl(Supplier<A> supplier,
205-
BiConsumer<A, T> accumulator,
206-
BinaryOperator<A> combiner,
207-
Function<A,R> finisher,
208-
Set<Characteristics> characteristics) {
209-
this.supplier = supplier;
210-
this.accumulator = accumulator;
211-
this.combiner = combiner;
212-
this.finisher = finisher;
213-
this.characteristics = characteristics;
214-
}
197+
record CollectorImpl<T, A, R>(Supplier<A> supplier,
198+
BiConsumer<A, T> accumulator,
199+
BinaryOperator<A> combiner,
200+
Function<A, R> finisher,
201+
Set<Characteristics> characteristics
202+
) implements Collector<T, A, R> {
215203

216204
CollectorImpl(Supplier<A> supplier,
217205
BiConsumer<A, T> accumulator,
218206
BinaryOperator<A> combiner,
219207
Set<Characteristics> characteristics) {
220208
this(supplier, accumulator, combiner, castingIdentity(), characteristics);
221209
}
222-
223-
@Override
224-
public BiConsumer<A, T> accumulator() {
225-
return accumulator;
226-
}
227-
228-
@Override
229-
public Supplier<A> supplier() {
230-
return supplier;
231-
}
232-
233-
@Override
234-
public BinaryOperator<A> combiner() {
235-
return combiner;
236-
}
237-
238-
@Override
239-
public Function<A, R> finisher() {
240-
return finisher;
241-
}
242-
243-
@Override
244-
public Set<Characteristics> characteristics() {
245-
return characteristics;
246-
}
247210
}
248211

249212
/**

0 commit comments

Comments
 (0)