-
CSR
-
Resolution: Approved
-
P4
-
None
-
source
-
minimal
-
-
Java API
-
SE
Summary
Introduces Stream::gather(Gatherer)
, the java.util.stream.Gatherer
interface, and the class for built-in Gatherer operations named java.util.stream.Gatherers
.
Problem
java.util.stream.Stream
does not have an intermediate operation which allows to serve as a vehicle for implementing generic user-defined intermediate operations.
Solution
We introduce java.util.stream.Stream::gather(Gatherer)
as the entry-point for attaching user-defined intermediate operations -- "Stream Gatherers". In order to ensure binary compatibility, a default implementation of this method is provided.
We also define the java.util.stream.Gatherer
interface, which allows the Java Standard Library, and Java developers, to implement new intermediate operations that can be attached to java.util.stream.Stream
using the gather(Gatherer)
-method. Gatherer's API design is heavily inspired by java.util.stream.Collector
, and the runtime evaluation thereof draws from existing implementations in the JDK.
In order to provide built-in Gatherers to Java developers, the java.util.stream.Gatherers
class is introduced, which exposes the following public static methods: fold
, mapConcurrent
, scan
, windowFixed
, windowSliding
-- and all of them return a Gatherer describing that respective operation given a set of parameter values.
Alternatives have been discussed here.
Specification
See attached specdiff archive.
For more details, see: https://github.com/openjdk/jdk/pull/16420
- csr of
-
JDK-8319123 Implement JEP 461: Stream Gatherers (Preview)
- Resolved