Gatherer
interface Gatherer<T : Any!, A : Any!, R : Any!>
java.util.stream.Gatherer |
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.
Summary
Nested classes | |
---|---|
abstract |
A Downstream object is the next stage in a pipeline of operations, to which elements can be sent. |
abstract |
An Integrator receives elements and processes them, optionally using the supplied state, and optionally sends incremental results downstream. |
Public methods | |
---|---|
open Gatherer<T, *, RR>! |
Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer. |
open BinaryOperator<A>! |
combiner() A function which accepts two intermediate states and combines them into one. |
open static BinaryOperator<A>! |
Returns a combiner which is the default combiner of a Gatherer. |
open static BiConsumer<A, Gatherer.Downstream<in R>!>! |
Returns a |
open static Supplier<A>! |
Returns an initializer which is the default initializer of a Gatherer. |
open BiConsumer<A, Gatherer.Downstream<in R>!>! |
finisher() A function which accepts the final intermediate state and a |
open Supplier<A>! |
A function that produces an instance of the intermediate state used for this gathering operation. |
abstract Gatherer.Integrator<A, T, R>! |
A function which integrates provided elements, potentially using the provided intermediate state, optionally producing output to the provided |
open static Gatherer<T, A, R>! |
of(initializer: Supplier<A>!, integrator: Gatherer.Integrator<A, T, R>!, combiner: BinaryOperator<A>!, finisher: BiConsumer<A, Gatherer.Downstream<in R>!>!) Returns a new, parallelizable, |
open static Gatherer<T, Void!, R>! |
of(integrator: Gatherer.Integrator<Void!, T, R>!) Returns a new, parallelizable, and stateless |
open static Gatherer<T, Void!, R>! |
of(integrator: Gatherer.Integrator<Void!, T, R>!, finisher: BiConsumer<Void!, Gatherer.Downstream<in R>!>!) Returns a new, parallelizable, and stateless |
open static Gatherer<T, A, R>! |
ofSequential(initializer: Supplier<A>!, integrator: Gatherer.Integrator<A, T, R>!) Returns a new, sequential, |
open static Gatherer<T, A, R>! |
ofSequential(initializer: Supplier<A>!, integrator: Gatherer.Integrator<A, T, R>!, finisher: BiConsumer<A, Gatherer.Downstream<in R>!>!) Returns a new, sequential, |
open static Gatherer<T, Void!, R>! |
ofSequential(integrator: Gatherer.Integrator<Void!, T, R>!) Returns a new, sequential, and stateless |
open static Gatherer<T, Void!, R>! |
ofSequential(integrator: Gatherer.Integrator<Void!, T, R>!, finisher: BiConsumer<Void!, Gatherer.Downstream<in R>!>!) Returns a new, sequential, and stateless |
Public methods
andThen
open fun <RR : Any!> andThen(that: Gatherer<in R, *, out RR>!): Gatherer<T, *, RR>!
Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer.
Parameters | |
---|---|
that |
Gatherer<in R, *, out RR>!: the other gatherer |
<RR> |
The type of output of that Gatherer |
Return | |
---|---|
Gatherer<T, *, RR>! |
returns a composed Gatherer which connects the output of this Gatherer as input that Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the argument is null |
combiner
open fun combiner(): BinaryOperator<A>!
A function which accepts two intermediate states and combines them into one.
Return | |
---|---|
BinaryOperator<A>! |
a function which accepts two intermediate states and combines them into one |
defaultCombiner
open static fun <A : Any!> defaultCombiner(): BinaryOperator<A>!
Returns a combiner which is the default combiner of a Gatherer. The returned combiner identifies that the owning Gatherer must only be evaluated sequentially.
Parameters | |
---|---|
<A> |
the type of the state of the returned combiner |
Return | |
---|---|
BinaryOperator<A>! |
the instance of the default combiner |
See Also
defaultFinisher
open static fun <A : Any!, R : Any!> defaultFinisher(): BiConsumer<A, Gatherer.Downstream<in R>!>!
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.
Parameters | |
---|---|
<A> |
the type of the state of the returned finisher |
<R> |
the type of the Downstream of the returned finisher |
Return | |
---|---|
BiConsumer<A, Gatherer.Downstream<in R>!>! |
the instance of the default finisher |
See Also
defaultInitializer
open static fun <A : Any!> defaultInitializer(): Supplier<A>!
Returns an initializer which is the default initializer of a Gatherer. The returned initializer identifies that the owner Gatherer is stateless.
Parameters | |
---|---|
<A> |
the type of the state of the returned initializer |
Return | |
---|---|
Supplier<A>! |
the instance of the default initializer |
finisher
open fun finisher(): BiConsumer<A, Gatherer.Downstream<in R>!>!
A function which accepts the final intermediate state and a Downstream
object, allowing to perform a final action at the end of input elements.
Return | |
---|---|
BiConsumer<A, Gatherer.Downstream<in R>!>! |
a function which transforms the intermediate result to the final result(s) which are then passed on to the provided Downstream |
initializer
open fun initializer(): Supplier<A>!
A function that produces an instance of the intermediate state used for this gathering operation.
Return | |
---|---|
Supplier<A>! |
A function that produces an instance of the intermediate state used for this gathering operation |
integrator
abstract fun integrator(): Gatherer.Integrator<A, T, R>!
A function which integrates provided elements, potentially using the provided intermediate state, optionally producing output to the provided Downstream
.
Return | |
---|---|
Gatherer.Integrator<A, T, R>! |
a function which integrates provided elements, potentially using the provided state, optionally producing output to the provided Downstream |
of
open static fun <T : Any!, A : Any!, R : Any!> of(
initializer: Supplier<A>!,
integrator: Gatherer.Integrator<A, T, R>!,
combiner: BinaryOperator<A>!,
finisher: BiConsumer<A, Gatherer.Downstream<in R>!>!
): Gatherer<T, A, R>!
Returns a new, parallelizable, Gatherer
described by the given initializer
, integrator
, combiner
and finisher
.
Parameters | |
---|---|
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<in R>!>!: the finisher function for the new gatherer |
<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 |
Return | |
---|---|
Gatherer<T, A, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |
of
open static fun <T : Any!, R : Any!> of(integrator: Gatherer.Integrator<Void!, T, R>!): Gatherer<T, Void!, R>!
Returns a new, parallelizable, and stateless Gatherer
described by the given integrator
.
Parameters | |
---|---|
integrator |
Gatherer.Integrator<Void!, T, R>!: the integrator function for the new gatherer |
<T> |
the type of input elements for the new gatherer |
<R> |
the type of results for the new gatherer |
Return | |
---|---|
Gatherer<T, Void!, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |
of
open static fun <T : Any!, R : Any!> of(
integrator: Gatherer.Integrator<Void!, T, R>!,
finisher: BiConsumer<Void!, Gatherer.Downstream<in R>!>!
): Gatherer<T, Void!, R>!
Returns a new, parallelizable, and stateless Gatherer
described by the given integrator
and finisher
.
Parameters | |
---|---|
integrator |
Gatherer.Integrator<Void!, T, R>!: the integrator function for the new gatherer |
finisher |
BiConsumer<Void!, Gatherer.Downstream<in R>!>!: the finisher function for the new gatherer |
<T> |
the type of input elements for the new gatherer |
<R> |
the type of results for the new gatherer |
Return | |
---|---|
Gatherer<T, Void!, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |
ofSequential
open static fun <T : Any!, A : Any!, R : Any!> ofSequential(
initializer: Supplier<A>!,
integrator: Gatherer.Integrator<A, T, R>!
): Gatherer<T, A, R>!
Returns a new, sequential, Gatherer
described by the given initializer
and integrator
.
Parameters | |
---|---|
initializer |
Supplier<A>!: the initializer function for the new gatherer |
integrator |
Gatherer.Integrator<A, T, R>!: the integrator function for the new gatherer |
<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 |
Return | |
---|---|
Gatherer<T, A, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |
ofSequential
open static fun <T : Any!, A : Any!, R : Any!> ofSequential(
initializer: Supplier<A>!,
integrator: Gatherer.Integrator<A, T, R>!,
finisher: BiConsumer<A, Gatherer.Downstream<in R>!>!
): Gatherer<T, A, R>!
Returns a new, sequential, Gatherer
described by the given initializer
, integrator
, and finisher
.
Parameters | |
---|---|
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<in R>!>!: the finisher function for the new gatherer |
<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 |
Return | |
---|---|
Gatherer<T, A, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |
ofSequential
open static fun <T : Any!, R : Any!> ofSequential(integrator: Gatherer.Integrator<Void!, T, R>!): Gatherer<T, Void!, R>!
Returns a new, sequential, and stateless Gatherer
described by the given integrator
.
Parameters | |
---|---|
integrator |
Gatherer.Integrator<Void!, T, R>!: the integrator function for the new gatherer |
<T> |
the type of input elements for the new gatherer |
<R> |
the type of results for the new gatherer |
Return | |
---|---|
Gatherer<T, Void!, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the argument is null |
ofSequential
open static fun <T : Any!, R : Any!> ofSequential(
integrator: Gatherer.Integrator<Void!, T, R>!,
finisher: BiConsumer<Void!, Gatherer.Downstream<in R>!>!
): Gatherer<T, Void!, R>!
Returns a new, sequential, and stateless Gatherer
described by the given integrator
and finisher
.
Parameters | |
---|---|
integrator |
Gatherer.Integrator<Void!, T, R>!: the integrator function for the new gatherer |
finisher |
BiConsumer<Void!, Gatherer.Downstream<in R>!>!: the finisher function for the new gatherer |
<T> |
the type of input elements for the new gatherer |
<R> |
the type of results for the new gatherer |
Return | |
---|---|
Gatherer<T, Void!, R>! |
the new Gatherer |
Exceptions | |
---|---|
java.lang.NullPointerException |
if any argument is null |