Integrator

@FunctionalInterface interface Integrator<A : Any!, T : Any!, R : Any!>
java.util.stream.Gatherer.Integrator

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

Summary

Nested classes
abstract

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

Public methods
abstract Boolean
integrate(state: A, element: T, downstream: Gatherer.Downstream<in R>!)

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.

open static Gatherer.Integrator<A, T, R>!
of(integrator: Gatherer.Integrator<A, T, R>!)

Factory method for turning Integrator-shaped lambdas into Integrators.

open static Gatherer.Integrator.Greedy<A, T, R>!
ofGreedy(greedy: Gatherer.Integrator.Greedy<A, T, R>!)

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

Public methods

integrate

abstract fun integrate(
    state: A,
    element: T,
    downstream: Gatherer.Downstream<in R>!
): Boolean

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<in R>!: The downstream object of this integration
Return
Boolean true if subsequent integration is desired, false if not

of

open static fun <A : Any!, T : Any!, R : Any!> of(integrator: Gatherer.Integrator<A, T, R>!): Gatherer.Integrator<A, T, R>!

Factory method for turning Integrator-shaped lambdas into Integrators.

Parameters
integrator Gatherer.Integrator<A, T, R>!: a lambda to create as Integrator
<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
Return
Gatherer.Integrator<A, T, R>! the given lambda as an Integrator

ofGreedy

open static fun <A : Any!, T : Any!, R : Any!> ofGreedy(greedy: Gatherer.Integrator.Greedy<A, T, R>!): Gatherer.Integrator.Greedy<A, T, R>!

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

Parameters
greedy Gatherer.Integrator.Greedy<A, T, R>!: a lambda to create as Integrator.Greedy
<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
Return
Gatherer.Integrator.Greedy<A, T, R>! the given lambda as a Greedy Integrator