Gatherer JavaDoc

Cay Horstmann cay.horstmann at gmail.com
Thu Jun 19 10:25:05 UTC 2025


Hi, I have trio of minor questions about the Gatherer JavaDoc at https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/util/stream/Gatherer.html

1. "Gatherers whose integrator is an instance of Gatherer.Integrator.Greedy can be assumed not to short-circuit, *and the return value of invoking Gatherer.Integrator.integrate(Object, Object, Downstream) does not need to be inspected*."

The way it is worded, I get the impression that a greedy integrator could simply return false (or to save a letter, true), because, not inspected. But I am confused. It was my impression that any integrator, greedy or not, should return false if downstream.push returns false. Why would the implementation not want to know? (The current implementation does inspect the return value.)

2. "Gatherers whose finisher is defaultFinisher() are considered to not have an end-of-stream hook *and invoking their finisher is optional.*"

I don't get the significance of the "and" part. Why would anyone care if defaultFinisher is invoked? It's a no-op.

3. What is the use case for

static <T,R> Gatherer<T,Void,R>
of(Gatherer.Integrator<Void,T,R> integrator, BiConsumer<Void, Gatherer.Downstream<? super R>> finisher)

If there is no state, what can the finisher do?

Thanks,

Cay

-- 

Cay S. Horstmann | https://horstmann.com



More information about the core-libs-dev mailing list