Interface MergingCollector<T,A,R>

Type Parameters:
T - the type of input elements to the reduction operation
A - the mutable accumulation type of the reduction operation (often hidden as an implementation detail)
R - the result type of the reduction operation
All Superinterfaces:
Collector<T,A,R>
All Known Subinterfaces:
DoubleCollector<A,R>, IntCollector<A,R>, LongCollector<A,R>
All Known Implementing Classes:
Internals.BaseCollector, Internals.DoubleCollectorImpl, Internals.IntCollectorImpl, Internals.LongCollectorImpl, Internals.PartialCollector

interface MergingCollector<T,A,R> extends Collector<T,A,R>
A MergingCollector is a Collector with more specific combining algorithm. Instead of providing a combiner which can create new partial result the MergingCollector must provide a merger which merges the second partial result into the first one.
  • Method Details

    • merger

      BiConsumer<A,A> merger()
      A function that merges the second partial result into the first partial result.
      Returns:
      a function that merges the second partial result into the first partial result.
    • combiner

      default BinaryOperator<A> combiner()
      A function that accepts two partial results and combines them returning either existing partial result or new one.

      The default implementation calls the merger() and returns the first partial result.

      Specified by:
      combiner in interface Collector<T,A,R>
      Returns:
      a function which combines two partial results into a combined result