Skip to content
Buy me a coffee

Gatherer

Gatherer: object

Defined in: src/stream/Gatherers.ts:14

Factories for Gatherer and the default* sentinels. The stateless overloads use a null state.

ofSequential(a, b) is resolved at runtime: a function declaring no parameters (and not marked greedy) is read as an initializer, so that call means ofSequential(initializer, integrator); otherwise it means ofSequential(integrator, finisher). An integrator that declares no parameters must use another overload.

of: {<T, R>(integrator): DefinedGatherer<T, null, R>; <T, R>(integrator, finisher): DefinedGatherer<T, null, R>; <T, A, R>(initializer, integrator, combiner, finisher): DefinedGatherer<T, A, R>; }

Returns a parallel-capable gatherer: of(integrator) and of(integrator, finisher) are stateless; of(initializer, integrator, combiner, finisher) has state that combiner must merge correctly. Evaluation is sequential either way, so this only declares that the gatherer is parallel-safe.

<T, R>(integrator): DefinedGatherer<T, null, R>

T

R

Integrator<null, T, R>

DefinedGatherer<T, null, R>

<T, R>(integrator, finisher): DefinedGatherer<T, null, R>

T

R

Integrator<null, T, R>

Finisher<null, R>

DefinedGatherer<T, null, R>

<T, A, R>(initializer, integrator, combiner, finisher): DefinedGatherer<T, A, R>

T

A

R

Initializer<A>

Integrator<A, T, R>

Combiner<A>

Finisher<A, R>

DefinedGatherer<T, A, R>

NullPointerException if any argument is null

ofSequential: {<T, R>(integrator): DefinedGatherer<T, null, R>; <T, A, R>(initializer, integrator): DefinedGatherer<T, A, R>; <T, R>(integrator, finisher): DefinedGatherer<T, null, R>; <T, A, R>(initializer, integrator, finisher): DefinedGatherer<T, A, R>; }

Returns a sequential-only gatherer (default combiner): (integrator), (initializer, integrator), (integrator, finisher) or (initializer, integrator, finisher). The two-argument forms are told apart at run time by the first function’s declared parameter count: with none (and not greedy) it is the initializer.

<T, R>(integrator): DefinedGatherer<T, null, R>

T

R

Integrator<null, T, R>

DefinedGatherer<T, null, R>

<T, A, R>(initializer, integrator): DefinedGatherer<T, A, R>

T

A

R

Initializer<A>

Integrator<A, T, R>

DefinedGatherer<T, A, R>

<T, R>(integrator, finisher): DefinedGatherer<T, null, R>

T

R

Integrator<null, T, R>

Finisher<null, R>

DefinedGatherer<T, null, R>

<T, A, R>(initializer, integrator, finisher): DefinedGatherer<T, A, R>

T

A

R

Initializer<A>

Integrator<A, T, R>

Finisher<A, R>

DefinedGatherer<T, A, R>

NullPointerException if any argument is null

defaultCombiner<A>(): Combiner<A>

Returns the default combiner: the same instance on every call; it marks a gatherer sequential-only. Calling it throws UnsupportedOperationException.

A

Combiner<A>

defaultFinisher<A, R>(): Finisher<A, R>

Returns the default finisher: the same instance on every call; it marks a gatherer as having no finishing action. Calling it does nothing.

A

R

Finisher<A, R>

defaultInitializer<A>(): Initializer<A>

Returns the default initializer: the same instance on every call; it marks a gatherer stateless. Calling it returns null.

A

Initializer<A>