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:
    java.util.stream.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 java.util.stream.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.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.stream.Collector

        java.util.stream.Collector.Characteristics
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.function.BinaryOperator<A> combiner()
      A function that accepts two partial results and combines them returning either existing partial result or new one.
      java.util.function.BiConsumer<A,​A> merger()
      A function that merges the second partial result into the first partial result.
      • Methods inherited from interface java.util.stream.Collector

        accumulator, characteristics, finisher, supplier
    • Method Detail

      • merger

        java.util.function.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 java.util.function.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 java.util.stream.Collector<T,​A,​R>
        Returns:
        a function which combines two partial results into a combined result