Top Description Inners Methods
java.util.stream

public Interface Gatherer<T, A, R>

Known Direct Implementers
java.util.stream.Gatherers.GathererImpl, java.util.stream.Gatherers.Composite
Annotations
@PreviewFeature
feature:STREAM_GATHERERS
Type Parameters
<T>
the type of input elements to the gatherer operation
<A>
the potentially mutable state type of the gatherer operation (often hidden as an implementation detail)
<R>
the type of output elements from the gatherer operation
Imports
jdk.internal.javac.PreviewFeature, jdk.internal.vm.annotation.ForceInline, java.util.*, java.util.function.BiConsumer, .BinaryOperator, .Supplier

Preview

Second Preview of Stream Gatherers (JEP 473).

Programs can only use Gatherer when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

An intermediate operation that transforms a stream of input elements into a stream of output elements, optionally applying a final action when the end of the upstream is reached. The transformation may be stateless or stateful, and may buffer input before producing any output.

Gatherer operations can be performed either sequentially, or be parallelized -- if a combiner function is supplied.

There are many examples of gathering operations, including but not limited to: grouping elements into batches (windowing functions); de-duplicating consecutively similar elements; incremental accumulation functions (prefix scan); incremental reordering functions, etc. The class java.util.stream.Gatherers provides implementations of common gathering operations.

API Note

A Gatherer is specified by four functions that work together to process input elements, optionally using intermediate state, and optionally perform a final action at the end of input. They are:

Each invocation of initializer(), integrator(), combiner(), and finisher() must return a semantically identical result.

Implementations of Gatherer must not capture, retain, or expose to other threads, the references to the state instance, or the downstream Downstream for longer than the invocation duration of the method which they are passed to.

Performing a gathering operation with a Gatherer should produce a result equivalent to:

Gatherer.Downstream<? super R> downstream = ...; A state = gatherer.initializer().get(); for (T t : data) { gatherer.integrator().integrate(state, t, downstream); } gatherer.finisher().accept(state, downstream);
Gatherer.Downstream<? super R> downstream = ...;
A state = gatherer.initializer().get();
for (T t : data) {
    gatherer.integrator().integrate(state, t, downstream);
}
gatherer.finisher().accept(state, downstream);

However, the library is free to partition the input, perform the integrations on the partitions, and then use the combiner function to combine the partial results to achieve a gathering operation. (Depending on the specific gathering operation, this may perform better or worse, depending on the relative cost of the integrator and combiner functions.)

In addition to the predefined implementations in Gatherers, the static factory methods of(...) and ofSequential(...) can be used to construct gatherers. For example, you could create a gatherer that implements the equivalent of java.util.stream.Stream#map(java.util.function.Function) with:

public static <T, R> Gatherer<T, ?, R> map(Function<? super T, ? extends R> mapper) { return Gatherer.of( (unused, element, downstream) -> // integrator downstream.push(mapper.apply(element)) ); }
public static <T, R> Gatherer<T, ?, R> map(Function<? super T, ? extends R> mapper) {
    return Gatherer.of(
        (unused, element, downstream) -> // integrator
            downstream.push(mapper.apply(element))
    );
}

Gatherers are designed to be composed; two or more Gatherers can be composed into a single Gatherer using the andThen(Gatherer) method.

// using the implementation of `map` as seen above Gatherer<Integer, ?, Integer> increment = map(i -> i + 1); Gatherer<Object, ?, String> toString = map(i -> i.toString()); Gatherer<Integer, ?, String> incrementThenToString = increment.andThen(toString);
// using the implementation of `map` as seen above
Gatherer<Integer, ?, Integer> increment = map(i -> i + 1);

Gatherer<Object, ?, String> toString = map(i -> i.toString());

Gatherer<Integer, ?, String> incrementThenToString = increment.andThen(toString);

As an example, a Gatherer implementing a sequential Prefix Scan could be done the following way:

public static <T, R> Gatherer<T, ?, R> scan( Supplier<R> initial, BiFunction<? super R, ? super T, ? extends R> scanner) { class State { R current = initial.get(); } return Gatherer.<T, State, R>ofSequential( State::new, Gatherer.Integrator.ofGreedy((state, element, downstream) -> { state.current = scanner.apply(state.current, element); return downstream.push(state.current); }) ); }
public static <T, R> Gatherer<T, ?, R> scan(
    Supplier<R> initial,
    BiFunction<? super R, ? super T, ? extends R> scanner) {

    class State {
        R current = initial.get();
    }

    return Gatherer.<T, State, R>ofSequential(
         State::new,
         Gatherer.Integrator.ofGreedy((state, element, downstream) -> {
             state.current = scanner.apply(state.current, element);
             return downstream.push(state.current);
         })
    );
}

Example of usage:

// will contain: ["1", "12", "123", "1234", "12345", "123456", "1234567", "12345678", "123456789"] List<String> numberStrings = Stream.of(1,2,3,4,5,6,7,8,9) .gather( scan(() -> "", (string, number) -> string + number) ) .toList();
// will contain: ["1", "12", "123", "1234", "12345", "123456", "1234567", "12345678", "123456789"]
List<String> numberStrings =
    Stream.of(1,2,3,4,5,6,7,8,9)
          .gather(
              scan(() -> "", (string, number) -> string + number)
           )
          .toList();

Implementation Specification

Libraries that implement transformations based on Gatherer, such as Stream#gather(Gatherer), must adhere to the following constraints:

Since
22
See Also
Stream#gather(Gatherer), Gatherers

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Gatherer.Downstream<
the type of elements this downstream accepts
T
>

Preview Second Preview of Stream Gatherers (JEP 473).

A Downstream object is the next stage in a pipeline of operations, to which elements can be sent.
public static interface
Gatherer.Integrator<
the type of state used by this integrator
A
,
the type of elements this integrator consumes
T
,
the type of results this integrator can produce
R
>

Preview Second Preview of Stream Gatherers (JEP 473).

An Integrator receives elements and processes them, optionally using the supplied state, and optionally sends incremental results downstream.

Method Summary

Modifier and TypeMethod and Description
public default <
The type of output of that Gatherer
RR
>
Gatherer<T, ?, RR>

Returns:

returns a composed Gatherer which connects the output of this Gatherer as input that Gatherer
andThen
(Gatherer<? super R, ?, ? extends RR>
the other gatherer
that
)

Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer.

public default BinaryOperator<A>

Returns:

a function which accepts two intermediate states and combines them into one
combiner
()

A function which accepts two intermediate states and combines them into one.

public static <
the type of the state of the returned combiner
A
>
BinaryOperator<A>

Returns:

the instance of the default combiner
defaultCombiner
()

Returns a combiner which is the default combiner of a Gatherer.

public static <
the type of the state of the returned finisher
A
,
the type of the Downstream of the returned finisher
R
>
BiConsumer<A, Gatherer.Downstream<? super R>>

Returns:

the instance of the default finisher
defaultFinisher
()

Returns a finisher which is the default finisher of a Gatherer.

public static <
the type of the state of the returned initializer
A
>
Supplier<A>

Returns:

the instance of the default initializer
defaultInitializer
()

Returns an initializer which is the default initializer of a Gatherer.

public default BiConsumer<A, Gatherer.Downstream<? super R>>

Returns:

a function which transforms the intermediate result to the final result(s) which are then passed on to the provided Downstream
finisher
()

A function which accepts the final intermediate state and a Downstream object, allowing to perform a final action at the end of input elements.

public default Supplier<A>

Returns:

A function that produces an instance of the intermediate state used for this gathering operation
initializer
()

A function that produces an instance of the intermediate state used for this gathering operation.

public Gatherer.Integrator<A, T, R>

Returns:

a function which integrates provided elements, potentially using the provided state, optionally producing output to the provided Downstream
integrator
()

A function which integrates provided elements, potentially using the provided intermediate state, optionally producing output to the provided Downstream.

public static <
the type of input elements for the new gatherer
T
,
the type of results for the new gatherer
R
>
Gatherer<T, Void, R>

Returns:

the new Gatherer
of
(Gatherer.Integrator<Void, T, R>
the integrator function for the new gatherer
integrator
)

Returns a new, parallelizable, and stateless Gatherer described by the given integrator.

public static <
the type of input elements for the new gatherer
T
,
the type of results for the new gatherer
R
>
Gatherer<T, Void, R>

Returns:

the new Gatherer
of
(Gatherer.Integrator<Void, T, R>
the integrator function for the new gatherer
integrator
,
BiConsumer<Void, Gatherer.Downstream<? super R>>
the finisher function for the new gatherer
finisher
)

Returns a new, parallelizable, and stateless Gatherer described by the given integrator and finisher.

public static <
the type of input elements for the new gatherer
T
,
the type of state for the new gatherer
A
,
the type of results for the new gatherer
R
>
Gatherer<T, A, R>

Returns:

the new Gatherer
of
(Supplier<A>
the initializer function for the new gatherer
initializer
,
Gatherer.Integrator<A, T, R>
the integrator function for the new gatherer
integrator
,
BinaryOperator<A>
the combiner function for the new gatherer
combiner
,
BiConsumer<A, Gatherer.Downstream<? super R>>
the finisher function for the new gatherer
finisher
)

Returns a new, parallelizable, Gatherer described by the given initializer, integrator, combiner and finisher.

public static <
the type of input elements for the new gatherer
T
,
the type of results for the new gatherer
R
>
Gatherer<T, Void, R>

Returns:

the new Gatherer
ofSequential
(Gatherer.Integrator<Void, T, R>
the integrator function for the new gatherer
integrator
)

Returns a new, sequential, and stateless Gatherer described by the given integrator.

public static <
the type of input elements for the new gatherer
T
,
the type of results for the new gatherer
R
>
Gatherer<T, Void, R>

Returns:

the new Gatherer
ofSequential
(Gatherer.Integrator<Void, T, R>
the integrator function for the new gatherer
integrator
,
BiConsumer<Void, Gatherer.Downstream<? super R>>
the finisher function for the new gatherer
finisher
)

Returns a new, sequential, and stateless Gatherer described by the given integrator and finisher.

public static <
the type of input elements for the new gatherer
T
,
the type of state for the new gatherer
A
,
the type of results for the new gatherer
R
>
Gatherer<T, A, R>

Returns:

the new Gatherer
ofSequential
(Supplier<A>
the initializer function for the new gatherer
initializer
,
Gatherer.Integrator<A, T, R>
the integrator function for the new gatherer
integrator
)

Returns a new, sequential, Gatherer described by the given initializer and integrator.

public static <
the type of input elements for the new gatherer
T
,
the type of state for the new gatherer
A
,
the type of results for the new gatherer
R
>
Gatherer<T, A, R>

Returns:

the new Gatherer
ofSequential
(Supplier<A>
the initializer function for the new gatherer
initializer
,
Gatherer.Integrator<A, T, R>
the integrator function for the new gatherer
integrator
,
BiConsumer<A, Gatherer.Downstream<? super R>>
the finisher function for the new gatherer
finisher
)

Returns a new, sequential, Gatherer described by the given initializer, integrator, and finisher.

Method Detail

andThenback to summary
public default <RR> Gatherer<T, ?, RR> andThen(Gatherer<? super R, ?, ? extends RR> that)

Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer.

Implementation Specification

The implementation in this interface returns a new Gatherer which is semantically equivalent to the combination of this and that gatherer.

Parameters
<RR>
The type of output of that Gatherer
that:Gatherer<? super R, ?, ? extends RR>

the other gatherer

Returns:Gatherer<T, ?, RR>

returns a composed Gatherer which connects the output of this Gatherer as input that Gatherer

Exceptions
NullPointerException:
if the argument is null
combinerback to summary
public default BinaryOperator<A> combiner()

A function which accepts two intermediate states and combines them into one.

Implementation Specification

The implementation in this interface returns defaultCombiner().

Returns:BinaryOperator<A>

a function which accepts two intermediate states and combines them into one

defaultCombinerback to summary
public static <A> BinaryOperator<A> defaultCombiner()

Returns a combiner which is the default combiner of a Gatherer. The returned combiner identifies that the owning Gatherer must only be evaluated sequentially.

Implementation Specification

This method always returns the same instance.

Parameters
<A>
the type of the state of the returned combiner
Returns:BinaryOperator<A>

the instance of the default combiner

See Also
Gatherer#combiner()
defaultFinisherback to summary
public static <A, R> BiConsumer<A, Gatherer.Downstream<? super R>> defaultFinisher()

Returns a finisher which is the default finisher of a Gatherer. The returned finisher identifies that the owning Gatherer performs no additional actions at the end of input.

Implementation Specification

This method always returns the same instance.

Parameters
<A>
the type of the state of the returned finisher
<R>
the type of the Downstream of the returned finisher
Returns:BiConsumer<A, Gatherer.Downstream<? super R>>

the instance of the default finisher

See Also
Gatherer#finisher()
defaultInitializerback to summary
public static <A> Supplier<A> defaultInitializer()

Returns an initializer which is the default initializer of a Gatherer. The returned initializer identifies that the owner Gatherer is stateless.

Implementation Specification

This method always returns the same instance.

Parameters
<A>
the type of the state of the returned initializer
Returns:Supplier<A>

the instance of the default initializer

See Also
Gatherer#initializer()
finisherback to summary
public default BiConsumer<A, Gatherer.Downstream<? super R>> finisher()

A function which accepts the final intermediate state and a Downstream object, allowing to perform a final action at the end of input elements.

Implementation Specification

The implementation in this interface returns defaultFinisher().

Returns:BiConsumer<A, Gatherer.Downstream<? super R>>

a function which transforms the intermediate result to the final result(s) which are then passed on to the provided Downstream

initializerback to summary
public default Supplier<A> initializer()

A function that produces an instance of the intermediate state used for this gathering operation.

Implementation Specification

The implementation in this interface returns defaultInitializer().

Returns:Supplier<A>

A function that produces an instance of the intermediate state used for this gathering operation

integratorback to summary
public Gatherer.Integrator<A, T, R> integrator()

A function which integrates provided elements, potentially using the provided intermediate state, optionally producing output to the provided Downstream.

Returns:Gatherer.Integrator<A, T, R>

a function which integrates provided elements, potentially using the provided state, optionally producing output to the provided Downstream

ofback to summary
public static <T, R> Gatherer<T, Void, R> of(Gatherer.Integrator<Void, T, R> integrator)

Returns a new, parallelizable, and stateless Gatherer described by the given integrator.

Parameters
<T>
the type of input elements for the new gatherer
<R>
the type of results for the new gatherer
integrator:Gatherer.Integrator<Void, T, R>

the integrator function for the new gatherer

Returns:Gatherer<T, Void, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
ofback to summary
public static <T, R> Gatherer<T, Void, R> of(Gatherer.Integrator<Void, T, R> integrator, BiConsumer<Void, Gatherer.Downstream<? super R>> finisher)

Returns a new, parallelizable, and stateless Gatherer described by the given integrator and finisher.

Parameters
<T>
the type of input elements for the new gatherer
<R>
the type of results for the new gatherer
integrator:Gatherer.Integrator<Void, T, R>

the integrator function for the new gatherer

finisher:BiConsumer<Void, Gatherer.Downstream<? super R>>

the finisher function for the new gatherer

Returns:Gatherer<T, Void, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
ofback to summary
public static <T, A, R> Gatherer<T, A, R> of(Supplier<A> initializer, Gatherer.Integrator<A, T, R> integrator, BinaryOperator<A> combiner, BiConsumer<A, Gatherer.Downstream<? super R>> finisher)

Returns a new, parallelizable, Gatherer described by the given initializer, integrator, combiner and finisher.

Parameters
<T>
the type of input elements for the new gatherer
<A>
the type of state for the new gatherer
<R>
the type of results for the new gatherer
initializer:Supplier<A>

the initializer function for the new gatherer

integrator:Gatherer.Integrator<A, T, R>

the integrator function for the new gatherer

combiner:BinaryOperator<A>

the combiner function for the new gatherer

finisher:BiConsumer<A, Gatherer.Downstream<? super R>>

the finisher function for the new gatherer

Returns:Gatherer<T, A, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
ofSequentialback to summary
public static <T, R> Gatherer<T, Void, R> ofSequential(Gatherer.Integrator<Void, T, R> integrator)

Returns a new, sequential, and stateless Gatherer described by the given integrator.

Parameters
<T>
the type of input elements for the new gatherer
<R>
the type of results for the new gatherer
integrator:Gatherer.Integrator<Void, T, R>

the integrator function for the new gatherer

Returns:Gatherer<T, Void, R>

the new Gatherer

Exceptions
NullPointerException:
if the argument is null
ofSequentialback to summary
public static <T, R> Gatherer<T, Void, R> ofSequential(Gatherer.Integrator<Void, T, R> integrator, BiConsumer<Void, Gatherer.Downstream<? super R>> finisher)

Returns a new, sequential, and stateless Gatherer described by the given integrator and finisher.

Parameters
<T>
the type of input elements for the new gatherer
<R>
the type of results for the new gatherer
integrator:Gatherer.Integrator<Void, T, R>

the integrator function for the new gatherer

finisher:BiConsumer<Void, Gatherer.Downstream<? super R>>

the finisher function for the new gatherer

Returns:Gatherer<T, Void, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
ofSequentialback to summary
public static <T, A, R> Gatherer<T, A, R> ofSequential(Supplier<A> initializer, Gatherer.Integrator<A, T, R> integrator)

Returns a new, sequential, Gatherer described by the given initializer and integrator.

Parameters
<T>
the type of input elements for the new gatherer
<A>
the type of state for the new gatherer
<R>
the type of results for the new gatherer
initializer:Supplier<A>

the initializer function for the new gatherer

integrator:Gatherer.Integrator<A, T, R>

the integrator function for the new gatherer

Returns:Gatherer<T, A, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
ofSequentialback to summary
public static <T, A, R> Gatherer<T, A, R> ofSequential(Supplier<A> initializer, Gatherer.Integrator<A, T, R> integrator, BiConsumer<A, Gatherer.Downstream<? super R>> finisher)

Returns a new, sequential, Gatherer described by the given initializer, integrator, and finisher.

Parameters
<T>
the type of input elements for the new gatherer
<A>
the type of state for the new gatherer
<R>
the type of results for the new gatherer
initializer:Supplier<A>

the initializer function for the new gatherer

integrator:Gatherer.Integrator<A, T, R>

the integrator function for the new gatherer

finisher:BiConsumer<A, Gatherer.Downstream<? super R>>

the finisher function for the new gatherer

Returns:Gatherer<T, A, R>

the new Gatherer

Exceptions
NullPointerException:
if any argument is null
java.util.stream back to summary

public Interface Gatherer.Downstream<T>

Known Direct Implementers
java.util.stream.GathererOp.GatherSink
Annotations
@FunctionalInterface
@PreviewFeature
feature:STREAM_GATHERERS
Type Parameters
<T>
the type of elements this downstream accepts

Preview

Second Preview of Stream Gatherers (JEP 473).

Programs can only use Downstream when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

A Downstream object is the next stage in a pipeline of operations, to which elements can be sent.
Since
22

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

true if this Downstream is known not to want any more elements sent to it, false if otherwise
isRejecting
()

Checks whether the next stage is known to not want any more elements sent to it.

public boolean

Returns:

true if more elements can be sent, and false if not.
push
(T
the element to push downstream
element
)

Pushes, if possible, the provided element downstream -- to the next stage in the pipeline.

Method Detail

isRejectingback to summary
public default boolean isRejecting()

Checks whether the next stage is known to not want any more elements sent to it.

API Note

This is best-effort only, once this returns true it should never return false again for the same instance.

Implementation Specification

The implementation in this interface returns false.

Returns:boolean

true if this Downstream is known not to want any more elements sent to it, false if otherwise

pushback to summary
public boolean push(T element)

Pushes, if possible, the provided element downstream -- to the next stage in the pipeline.

Implementation Specification

If this method returns false then no further elements will be accepted and subsequent invocations of this method will return false.

Parameters
element:T

the element to push downstream

Returns:boolean

true if more elements can be sent, and false if not.

java.util.stream back to summary

public Interface Gatherer.Integrator<A, T, R>

Known Direct Subinterfaces
java.util.stream.Gatherer.Integrator.Greedy
Annotations
@FunctionalInterface
@PreviewFeature
feature:STREAM_GATHERERS
Type Parameters
<A>
the type of state used by this integrator
<T>
the type of elements this integrator consumes
<R>
the type of results this integrator can produce

Preview

Second Preview of Stream Gatherers (JEP 473).

Programs can only use Integrator when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

An Integrator receives elements and processes them, optionally using the supplied state, and optionally sends incremental results downstream.
Since
22

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Gatherer.Integrator.Greedy<
the type of state used by this integrator
A
,
the type of elements this greedy integrator receives
T
,
the type of results this greedy integrator can produce
R
>

Preview Second Preview of Stream Gatherers (JEP 473).

Greedy Integrators consume all their input, and may only relay that the downstream does not want more elements.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if subsequent integration is desired, false if not
integrate
(A
The state to integrate into
state
,
T
The element to integrate
element
,
Gatherer.Downstream<? super R>
The downstream object of this integration
downstream
)

Performs an action given: the current state, the next element, and a downstream object; potentially inspecting and/or updating the state, optionally sending any number of elements downstream -- and then returns whether more elements are to be consumed or not.

public static <
the type of state used by this integrator
A
,
the type of elements this integrator receives
T
,
the type of results this integrator can produce
R
>
Gatherer.Integrator<A, T, R>

Returns:

the given lambda as an Integrator
of
(Gatherer.Integrator<A, T, R>
a lambda to create as Integrator
integrator
)

Factory method for turning Integrator-shaped lambdas into Integrators.

public static <
the type of state used by this integrator
A
,
the type of elements this integrator receives
T
,
the type of results this integrator can produce
R
>
Gatherer.Integrator.Greedy<A, T, R>

Returns:

the given lambda as a Greedy Integrator
ofGreedy
(Gatherer.Integrator.Greedy<A, T, R>
a lambda to create as Integrator.Greedy
greedy
)

Factory method for turning Integrator-shaped lambdas into Greedy Integrators.

Method Detail

integrateback to summary
public boolean integrate(A state, T element, Gatherer.Downstream<? super R> downstream)

Performs an action given: the current state, the next element, and a downstream object; potentially inspecting and/or updating the state, optionally sending any number of elements downstream -- and then returns whether more elements are to be consumed or not.

Parameters
state:A

The state to integrate into

element:T

The element to integrate

downstream:Gatherer.Downstream<? super R>

The downstream object of this integration

Returns:boolean

true if subsequent integration is desired, false if not

ofback to summary
public static <A, T, R> Gatherer.Integrator<A, T, R> of(Gatherer.Integrator<A, T, R> integrator)

Factory method for turning Integrator-shaped lambdas into Integrators.

Parameters
<A>
the type of state used by this integrator
<T>
the type of elements this integrator receives
<R>
the type of results this integrator can produce
integrator:Gatherer.Integrator<A, T, R>

a lambda to create as Integrator

Returns:Gatherer.Integrator<A, T, R>

the given lambda as an Integrator

Annotations
@ForceInline
ofGreedyback to summary
public static <A, T, R> Gatherer.Integrator.Greedy<A, T, R> ofGreedy(Gatherer.Integrator.Greedy<A, T, R> greedy)

Factory method for turning Integrator-shaped lambdas into Greedy Integrators.

Parameters
<A>
the type of state used by this integrator
<T>
the type of elements this integrator receives
<R>
the type of results this integrator can produce
greedy:Gatherer.Integrator.Greedy<A, T, R>

a lambda to create as Integrator.Greedy

Returns:Gatherer.Integrator.Greedy<A, T, R>

the given lambda as a Greedy Integrator

Annotations
@ForceInline
java.util.stream back to summary

public Interface Gatherer.Integrator.Greedy<A, T, R>

extends Gatherer.Integrator<A, T, R>
Annotations
@FunctionalInterface
@PreviewFeature
feature:STREAM_GATHERERS
Type Parameters
<A>
the type of state used by this integrator
<T>
the type of elements this greedy integrator receives
<R>
the type of results this greedy integrator can produce

Preview

Second Preview of Stream Gatherers (JEP 473).

Programs can only use Greedy when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

Greedy Integrators consume all their input, and may only relay that the downstream does not want more elements.

Implementation Specification

This interface is used to communicate that no short-circuiting will be initiated by this Integrator, and that information can then be used to optimize evaluation.

Since
22