org.optaplanner.core.api.score.stream.uni

## Interface UniConstraintCollector<A,ResultContainer_,Result_>

- Type Parameters:
    `A` - the type of the one and only fact of the tuple in the source `UniConstraintStream`
    `ResultContainer_` - the mutable accumulation type (often hidden as an implementation detail)
    `Result_` - the type of the fact of the tuple in the destination `ConstraintStream`
  All Known Implementing Classes:
    DefaultUniConstraintCollector

      public interface UniConstraintCollector<A,ResultContainer_,Result_>

  Usually created with `ConstraintCollectors`. Used by `UniConstraintStream.groupBy(Function, UniConstraintCollector)`, ...

  Loosely based on JDK's `Collector`, but it returns an undo operation for each accumulation to enable incremental score calculation in `constraint streams`.

  See Also:
    `ConstraintCollectors`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `BiFunction<ResultContainer_,A,Runnable>` | `accumulator()` A lambda that extracts data from the matched fact, accumulates it in the result container and returns an undo operation for that accumulation.
    `Function<ResultContainer_,Result_>` | `finisher()` A lambda that converts the result container into the result.
    `Supplier<ResultContainer_>` | `supplier()` A lambda that creates the result container, one for each group key combination.

- - ### Method Detail

    - #### supplier

          Supplier<ResultContainer_> supplier()

      A lambda that creates the result container, one for each group key combination.
      Returns:
        never null

    - #### accumulator

          BiFunction<ResultContainer_,A,Runnable> accumulator()

      A lambda that extracts data from the matched fact, accumulates it in the result container and returns an undo operation for that accumulation.
      Returns:
        never null, the undo operation. This lamdba is called when the fact no longer matches.

    - #### finisher

          Function<ResultContainer_,Result_> finisher()

      A lambda that converts the result container into the result.
      Returns:
        null when the result would be invalid, such as maximum value from an empty container.

Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.