An Integrator receives elements and processes them,
optionally using the supplied state, and optionally sends incremental
results downstream.
Nested classes |
interface |
Gatherer.Integrator.Greedy<A, T, R>
Greedy Integrators consume all their input, and may only relay that
the downstream does not want more elements.
|
Public methods |
abstract
boolean
|
integrate(A state, T element, 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.
|
static
<A, T, R>
Integrator<A, T, R>
|
of(Integrator<A, T, R> integrator)
Factory method for turning Integrator-shaped lambdas into
Integrators.
|
static
<A, T, R>
Greedy<A, T, R>
|
ofGreedy(Greedy<A, T, R> greedy)
Factory method for turning Integrator-shaped lambdas into
Greedy Integrators.
|
Public methods
integrate
public abstract boolean integrate (A state,
T element,
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 |
Downstream : The downstream object of this integration |
Returns |
boolean |
true if subsequent integration is desired,
false if not |
of
public static Integrator<A, T, R> of (Integrator<A, T, R> integrator)
Factory method for turning Integrator-shaped lambdas into
Integrators.
Parameters |
integrator |
Integrator : a lambda to create as Integrator |
Returns |
Integrator<A, T, R> |
the given lambda as an Integrator |
ofGreedy
public static Greedy<A, T, R> ofGreedy (Greedy<A, T, R> greedy)
Factory method for turning Integrator-shaped lambdas into
Greedy
Integrators.
Parameters |
greedy |
Greedy : a lambda to create as Integrator.Greedy |
Returns |
Greedy<A, T, R> |
the given lambda as a Greedy Integrator |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# Gatherer.Integrator\n\n[**Added in Android Baklava**](/preview) \nSummary: [Nested Classes](#nestedclasses) \\| [Methods](#pubmethods) \n\nGatherer.Integrator\n===================\n\n\n`\npublic\nstatic\n\n\ninterface\nGatherer.Integrator\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------------|\n| java.util.stream.Gatherer.Integrator\\\u003cA, T, R\\\u003e |\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [Gatherer.Integrator.Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)\\\u003cA, T, R\\\u003e |-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| | [Gatherer.Integrator.Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)\\\u003cA, T, R\\\u003e | Greedy Integrators consume all their input, and may only relay that the downstream does not want more elements. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn Integrator receives elements and processes them,\noptionally using the supplied state, and optionally sends incremental\nresults downstream.\n\nSummary\n-------\n\n| ### Nested classes ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` interface` | [Gatherer.Integrator.Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)`\u003cA, T, R\u003e` Greedy Integrators consume all their input, and may only relay that the downstream does not want more elements. |\n\n| ### Public methods ||\n|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[integrate](/reference/java/util/stream/Gatherer.Integrator#integrate(A,%20T,%20java.util.stream.Gatherer.Downstream\u003c?%20super%20R\u003e))`(A state, T element, `[Downstream](/reference/java/util/stream/Gatherer.Downstream)`\u003c? super R\u003e 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. |\n| ` static \u003cA, T, R\u003e `[Integrator](/reference/java/util/stream/Gatherer.Integrator)`\u003cA, T, R\u003e` | ` `[of](/reference/java/util/stream/Gatherer.Integrator#of(java.util.stream.Gatherer.Integrator\u003cA,T,R\u003e))`(`[Integrator](/reference/java/util/stream/Gatherer.Integrator)`\u003cA, T, R\u003e integrator) ` Factory method for turning Integrator-shaped lambdas into Integrators. |\n| ` static \u003cA, T, R\u003e `[Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)`\u003cA, T, R\u003e` | ` `[ofGreedy](/reference/java/util/stream/Gatherer.Integrator#ofGreedy(java.util.stream.Gatherer.Integrator.Greedy\u003cA,T,R\u003e))`(`[Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)`\u003cA, T, R\u003e greedy) ` Factory method for turning Integrator-shaped lambdas into [Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy) Integrators. |\n\nPublic methods\n--------------\n\n### integrate\n\n[**Added in Android Baklava**](/preview) \n\n```\npublic abstract boolean integrate (A state, \n T element, \n Downstream\u003c? super R\u003e downstream)\n```\n\nPerforms an action given: the current state, the next element, and\na downstream object; potentially inspecting and/or updating\nthe state, optionally sending any number of elements downstream\n-- and then returns whether more elements are to be consumed or not.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|----------------------------------------------------------------|\n| `state` | `A`: The state to integrate into \u003cbr /\u003e |\n| `element` | `T`: The element to integrate \u003cbr /\u003e |\n| `downstream` | `Downstream`: The downstream object of this integration \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------|\n| `boolean` | `true` if subsequent integration is desired, `false` if not \u003cbr /\u003e |\n\n### of\n\n[**Added in Android Baklava**](/preview) \n\n```\npublic static Integrator\u003cA, T, R\u003e of (Integrator\u003cA, T, R\u003e integrator)\n```\n\nFactory method for turning Integrator-shaped lambdas into\nIntegrators.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|-------------------------------------------------------|\n| `integrator` | `Integrator`: a lambda to create as Integrator \u003cbr /\u003e |\n\n| Returns ||\n|--------------------------------------------------------------------------|------------------------------------------|\n| [Integrator](/reference/java/util/stream/Gatherer.Integrator)`\u003cA, T, R\u003e` | the given lambda as an Integrator \u003cbr /\u003e |\n\n### ofGreedy\n\n[**Added in Android Baklava**](/preview) \n\n```\npublic static Greedy\u003cA, T, R\u003e ofGreedy (Greedy\u003cA, T, R\u003e greedy)\n```\n\nFactory method for turning Integrator-shaped lambdas into\n[Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy) Integrators.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|----------------------------------------------------------|\n| `greedy` | `Greedy`: a lambda to create as Integrator.Greedy \u003cbr /\u003e |\n\n| Returns ||\n|-----------------------------------------------------------------------------|------------------------------------------------|\n| [Greedy](/reference/java/util/stream/Gatherer.Integrator.Greedy)`\u003cA, T, R\u003e` | the given lambda as a Greedy Integrator \u003cbr /\u003e |"]]