Gatherer that provide useful intermediate
operations, such as windowing functions, folding functions,
transforming elements concurrently, etc.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static record | |
| pack-priv static enum |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type of elements the returned gatherer consumes T, the type of elements the returned gatherer produces R> Gatherer | Returns: a new Gathererthe identity value for the fold operation initial, BiFunction<? super R, ? super T, ? extends R> the folding function folder)Returns a Gatherer that performs an ordered, reduction-like, transformation for scenarios where no combiner-function can be implemented, or for reductions which are intrinsically order-dependent. |
| public static < the type of input T, the type of output R> Gatherer | Returns: a new Gathererthe maximum concurrency desired maxConcurrency, final Function<? super T, ? extends R> a function to be executed concurrently mapper)An operation which executes a function concurrently with a configured level of max concurrency, using virtual threads. |
| public static < the type of element which this gatherer consumes T, the type of element which this gatherer produces R> Gatherer | Returns: a new Gatherer which performs a prefix scanthe supplier of the initial value for the scanner initial, BiFunction<? super R, ? super T, ? extends R> the function to apply for each element scanner)Returns a Gatherer that performs a Prefix Scan -- an incremental accumulation -- using the provided functions. |
| public static < the type of elements the returned gatherer consumes
and the contents of the windows it produces TR> Gatherer | Returns: a new gatherer which groups elements into fixed-size windowsthe size of the windows windowSize)Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a fixed size. |
| public static < the type of elements the returned gatherer consumes
and the contents of the windows it produces TR> Gatherer | Returns: a new gatherer which groups elements into sliding windowsthe size of the windows windowSize)Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a given size, where each subsequent window includes all elements of the previous window except for the least recent, and adds the next element in the stream. |
| Gatherers | back to summary |
|---|---|
| private Gatherers() | |
| fold | back to summary |
|---|---|
| public static <T, R> Gatherer Returns a Gatherer that performs an ordered, reduction-like, transformation for scenarios where no combiner-function can be implemented, or for reductions which are intrinsically order-dependent. Implementation Specification If no exceptions are thrown during processing, then this operation only ever produces a single element. Example: // will contain: Optional["123456789"] Optional<String> numberString = Stream.of(1,2,3,4,5,6,7,8,9) .gather( Gatherers.fold(() -> "", (string, number) -> string + number) ) .findFirst();
| |
| mapConcurrent | back to summary |
|---|---|
| public static <T, R> Gatherer An operation which executes a function concurrently with a configured level of max concurrency, using virtual threads. This operation preserves the ordering of the stream. API Note In progress tasks will be attempted to be cancelled, on a best-effort basis, in situations where the downstream no longer wants to receive any more elements. Implementation Specification If a result of the function is to be pushed downstream but
instead the function completed exceptionally then the corresponding
exception will instead be rethrown by this method as an instance of
| |
| scan | back to summary |
|---|---|
| public static <T, R> Gatherer Returns a Gatherer that performs a Prefix Scan -- an incremental
accumulation -- using the provided functions. Starting with an
initial value obtained from the Example: // 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( Gatherers.scan(() -> "", (string, number) -> string + number) ) .toList();
| |
| windowFixed | back to summary |
|---|---|
| public static <TR> Gatherer Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a fixed size. If the stream is empty then no window will be produced. The last window may contain fewer elements than the supplied window size. Example: // will contain: [[1, 2, 3], [4, 5, 6], [7, 8]] List<List<Integer>> windows = Stream.of(1,2,3,4,5,6,7,8).gather(Gatherers.windowFixed(3)).toList(); Implementation Specification Each window produced is an unmodifiable List; calls to any
mutator method will always cause API Note For efficiency reasons, windows may be allocated contiguously and eagerly. This means that choosing large window sizes for small streams may use excessive memory for the duration of evaluation of this operation.
| |
| windowSliding | back to summary |
|---|---|
| public static <TR> Gatherer Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a given size, where each subsequent window includes all elements of the previous window except for the least recent, and adds the next element in the stream. If the stream is empty then no window will be produced. If the size of the stream is smaller than the window size then only one window will be produced, containing all elements in the stream. Example: // will contain: [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]] List<List<Integer>> windows2 = Stream.of(1,2,3,4,5,6,7,8).gather(Gatherers.windowSliding(2)).toList(); // will contain: [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8]] List<List<Integer>> windows6 = Stream.of(1,2,3,4,5,6,7,8).gather(Gatherers.windowSliding(6)).toList(); Implementation Specification Each window produced is an unmodifiable List; calls to any
mutator method will always cause API Note For efficiency reasons, windows may be allocated contiguously and eagerly. This means that choosing large window sizes for small streams may use excessive memory for the duration of evaluation of this operation.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Gatherers. | |
| private final Gatherer | |
| private final Gatherer |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public <RRR> Gatherer | andThen(Gatherer<? super RR, ?, ? extends RRR> that)
Overrides default java. Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer. |
| public BinaryOperator | combiner()
Overrides default java. A function which accepts two intermediate states and combines them into one. |
| public BiConsumer | finisher()
Overrides default java. A function which accepts the final intermediate state
and a |
| private Gatherers. | |
| pack-priv static final <T, A, R, AA, RR> Gatherers. | |
| public Supplier | initializer()
Overrides default java. A function that produces an instance of the intermediate state used for this gathering operation. |
| public Gatherer. | integrator()
Implements java. A function which integrates provided elements, potentially using
the provided intermediate state, optionally producing output to the
provided |
| pack-priv static <T, A, R, AA, RR> Gatherers. |
| impl | back to summary |
|---|---|
| private Gatherers. | |
| left | back to summary |
|---|---|
| private final Gatherer<T, A, ? extends R> left | |
| right | back to summary |
|---|---|
| private final Gatherer<? super R, AA, ? extends RR> right | |
| Composite | back to summary |
|---|---|
| private Composite(Gatherer<T, A, ? extends R> left, Gatherer<? super R, AA, ? extends RR> right) | |
| andThen | back to summary |
|---|---|
| public <RRR> Gatherer Overrides default java. Doc from java. Returns a composed Gatherer which connects the output of this Gatherer to the input of that Gatherer.
| |
| combiner | back to summary |
|---|---|
| public BinaryOperator Overrides default java. Doc from java. A function which accepts two intermediate states and combines them into one.
| |
| finisher | back to summary |
|---|---|
| public BiConsumer Overrides default java. Doc from java. A function which accepts the final intermediate state
and a
| |
| impl | back to summary |
|---|---|
private Gatherers.
| |
| impl | back to summary |
|---|---|
| pack-priv static final <T, A, R, AA, RR> Gatherers. | |
| initializer | back to summary |
|---|---|
| public Supplier Overrides default java. Doc from java. A function that produces an instance of the intermediate state used for this gathering operation.
| |
| integrator | back to summary |
|---|---|
| public Gatherer. Implements java. Doc from java. A function which integrates provided elements, potentially using
the provided intermediate state, optionally producing output to the
provided
| |
| of | back to summary |
|---|---|
| pack-priv static <T, A, R, AA, RR> Gatherers. | |
| Modifier and Type | Field and Description |
|---|---|
| private final BinaryOperator | combiner
Record Component accessed by combiner(). |
| private final BiConsumer | finisher
Record Component accessed by finisher(). |
| private final Supplier | initializer
Record Component accessed by initializer(). |
| private final Gatherer. | integrator
Record Component accessed by integrator(). |
| Access | Constructor and Description |
|---|---|
| pack-priv | GathererImpl(Supplier<A> initializer, Gatherer.
|
| Modifier and Type | Method and Description |
|---|---|
| public BinaryOperator | combiner()
Record Component getter of combiner. Overrides default java. A function which accepts two intermediate states and combines them into one.
|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public BiConsumer | finisher()
Record Component getter of finisher. Overrides default java. A function which accepts the final intermediate state
and a
|
| public final int | |
| public Supplier | initializer()
Record Component getter of initializer. Overrides default java. A function that produces an instance of the intermediate state used for this gathering operation.
|
| public Gatherer. | integrator()
Record Component getter of integrator. Implements java. A function which integrates provided elements, potentially using
the provided intermediate state, optionally producing output to the
provided
|
| pack-priv static <T, A, R> Gatherers. | of(Supplier<A> initializer, Gatherer.
Hides java. Returns a new, parallelizable, |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| combiner | back to summary |
|---|---|
| private final BinaryOperator<A> combiner Record Component accessed by combiner(). | |
| finisher | back to summary |
|---|---|
| private final BiConsumer<A, Gatherer. Record Component accessed by finisher(). | |
| initializer | back to summary |
|---|---|
| private final Supplier<A> initializer Record Component accessed by initializer(). | |
| integrator | back to summary |
|---|---|
| private final Gatherer. Record Component accessed by integrator(). | |
| GathererImpl | back to summary |
|---|---|
| pack-priv GathererImpl(Supplier<A> initializer, Gatherer. | |
| combiner | back to summary |
|---|---|
| public BinaryOperator Record Component getter of combiner. Overrides default java. Doc from java. A function which accepts two intermediate states and combines them into one.
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| finisher | back to summary |
|---|---|
| public BiConsumer Record Component getter of finisher. Overrides default java. Doc from java. A function which accepts the final intermediate state
and a
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| initializer | back to summary |
|---|---|
| public Supplier Record Component getter of initializer. Overrides default java. Doc from java. A function that produces an instance of the intermediate state used for this gathering operation.
| |
| integrator | back to summary |
|---|---|
| public Gatherer. Record Component getter of integrator. Implements java. Doc from java. A function which integrates provided elements, potentially using
the provided intermediate state, optionally producing output to the
provided
| |
| of | back to summary |
|---|---|
| pack-priv static <T, A, R> Gatherers. Hides java. Doc from java. Returns a new, parallelizable, | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Gatherers. | |
| pack-priv final BinaryOperator |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | accept(Object state, Object downstream)
Implements java. Performs this operation on the given arguments. |
| public Object | apply(Object left, Object right)
Implements java. Applies this function to the given arguments. |
| pack-priv <T> BinaryOperator | |
| pack-priv <T, R> BiConsumer | |
| public Object | |
| pack-priv <A> Supplier | |
| public static Gatherers. | |
| public static Gatherers. |
| DEFAULT | back to summary |
|---|---|
| public static final Gatherers. | |
| statelessCombiner | back to summary |
|---|---|
| pack-priv final BinaryOperator<Void> statelessCombiner | |
| Value | back to summary |
|---|---|
| private Value() | |
| accept | back to summary |
|---|---|
| public void accept(Object state, Object downstream) Implements java. Doc from java. Performs this operation on the given arguments.
| |
| apply | back to summary |
|---|---|
| public Object apply(Object left, Object right) Implements java. Doc from java. Applies this function to the given arguments.
| |
| combiner | back to summary |
|---|---|
pack-priv <T> BinaryOperator
| |
| finisher | back to summary |
|---|---|
pack-priv <T, R> BiConsumer
| |
| get | back to summary |
|---|---|
| public Object get() Implements java. Doc from java. Gets a result.
| |
| initializer | back to summary |
|---|---|
pack-priv <A> Supplier
| |
| valueOf | back to summary |
|---|---|
| public static Gatherers. | |
| values | back to summary |
|---|---|
| public static Gatherers. | |