Module io.smallrye.mutiny
Package io.smallrye.mutiny.groups
Class Gatherers.DefaultGatherer<I,ACC,O>
java.lang.Object
io.smallrye.mutiny.groups.Gatherers.DefaultGatherer<I,ACC,O>
- Type Parameters:
I- the type of the items emitted by the upstreamACC- the type of the accumulatorO- the type of the items emitted to the downstream
- All Implemented Interfaces:
Gatherer<I,ACC, O>
- Enclosing interface:
Gatherers
Default implementation of the
Gatherer interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.smallrye.mutiny.groups.Gatherer
Gatherer.Builder<I>, Gatherer.Extraction<ACC,O>, Gatherer.ExtractStep<I, ACC>, Gatherer.FinalizerStep<I, ACC, O>, Gatherer.InitialAccumulatorStep<I, ACC> -
Constructor Summary
ConstructorsConstructorDescriptionDefaultGatherer(Supplier<ACC> initialAccumulatorSupplier, BiFunction<ACC, I, ACC> accumulatorFunction, BiFunction<ACC, Boolean, Optional<Gatherer.Extraction<ACC, O>>> extractor, Function<ACC, Optional<O>> finalizer) -
Method Summary
Modifier and TypeMethodDescriptionaccumulate(ACC accumulator, I item) Accumulates an item into the accumulator.Creates a new accumulator.Extracts an item from the accumulator.Finalizes the accumulator and extracts the final item, if any.
-
Constructor Details
-
DefaultGatherer
-
-
Method Details
-
accumulator
Description copied from interface:GathererCreates a new accumulator.- Specified by:
accumulatorin interfaceGatherer<I,ACC, O> - Returns:
- a new accumulator
-
accumulate
Description copied from interface:GathererAccumulates an item into the accumulator.- Specified by:
accumulatein interfaceGatherer<I,ACC, O> - Parameters:
accumulator- the current accumulatoritem- the item to accumulate- Returns:
- the updated accumulator
-
extract
Description copied from interface:GathererExtracts an item from the accumulator.- Specified by:
extractin interfaceGatherer<I,ACC, O> - Parameters:
accumulator- the current accumulatorupstreamCompleted- whether the upstream has completed- Returns:
- an Optional containing a Extraction with the updated accumulator and the extracted item, or an empty Optional if no item can be extracted
-
finalize
Description copied from interface:GathererFinalizes the accumulator and extracts the final item, if any. This method is called when the upstream has completed and no more items can be extracted using the extract method.
-