mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8231161: Wrong return type in code sample in Collector API documentation
Correct declaration of container from R to A and add compilation test Reviewed-by: smarks, lancea
This commit is contained in:
parent
f1a1fadb63
commit
4dafa3033f
2 changed files with 111 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,6 +33,10 @@ import java.util.function.BinaryOperator;
|
|||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
// A compilation test for the code snippets in this class-level javadoc can be found at:
|
||||
// test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectorExample.java
|
||||
// The test needs to be updated if the examples in this javadoc change or new examples are added.
|
||||
|
||||
/**
|
||||
* A <a href="package-summary.html#Reduction">mutable reduction operation</a> that
|
||||
* accumulates input elements into a mutable result container, optionally transforming
|
||||
|
@ -154,7 +158,7 @@ import java.util.function.Supplier;
|
|||
* Performing a reduction operation with a {@code Collector} should produce a
|
||||
* result equivalent to:
|
||||
* <pre>{@code
|
||||
* R container = collector.supplier().get();
|
||||
* A container = collector.supplier().get();
|
||||
* for (T t : data)
|
||||
* collector.accumulator().accept(container, t);
|
||||
* return collector.finisher().apply(container);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue