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 upstream
ACC - the type of the accumulator
O - the type of the items emitted to the downstream
All Implemented Interfaces:
Gatherer<I,ACC,O>
Enclosing interface:
Gatherers

public static class Gatherers.DefaultGatherer<I,ACC,O> extends Object implements Gatherer<I,ACC,O>
Default implementation of the Gatherer interface.
  • Constructor Details

  • Method Details

    • accumulator

      public ACC accumulator()
      Description copied from interface: Gatherer
      Creates a new accumulator.
      Specified by:
      accumulator in interface Gatherer<I,ACC,O>
      Returns:
      a new accumulator
    • accumulate

      public ACC accumulate(ACC accumulator, I item)
      Description copied from interface: Gatherer
      Accumulates an item into the accumulator.
      Specified by:
      accumulate in interface Gatherer<I,ACC,O>
      Parameters:
      accumulator - the current accumulator
      item - the item to accumulate
      Returns:
      the updated accumulator
    • extract

      public Optional<Gatherer.Extraction<ACC,O>> extract(ACC accumulator, boolean upstreamCompleted)
      Description copied from interface: Gatherer
      Extracts an item from the accumulator.
      Specified by:
      extract in interface Gatherer<I,ACC,O>
      Parameters:
      accumulator - the current accumulator
      upstreamCompleted - 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

      public Optional<O> finalize(ACC accumulator)
      Description copied from interface: Gatherer
      Finalizes 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.
      Specified by:
      finalize in interface Gatherer<I,ACC,O>
      Parameters:
      accumulator - the current accumulator
      Returns:
      an Optional containing the final item, or an empty Optional if no final item can be extracted