JEP 461 proposes Stream::gather
and Gatherer
- a new intermediate meta-operation that can be used to implement all kinds of specific operations, from existing ones like map
and sorted
to new ones like flatMapIf
and increasingSequence
.
Once you grokked the theory, it's time to put it into practice to implement more operations:
Implementing New Java Stream Operations
//
Implementing a bunch of Gatherer
s to better understand the proposed addition to the stream API