org.optaplanner.core.impl.score.stream.bavet.bi

## Class BavetAbstractBiConstraintStream<Solution_,A,B>

- java.lang.Object
- - org.optaplanner.core.impl.score.stream.common.AbstractConstraintStream<Solution_>
  - - org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream<Solution_>
    - - org.optaplanner.core.impl.score.stream.bavet.bi.BavetAbstractBiConstraintStream<Solution_,A,B>

- All Implemented Interfaces:
    BiConstraintStream<A,B>, ConstraintStream, InnerBiConstraintStream<A,B>
  Direct Known Subclasses:
    BavetFilterBiConstraintStream, BavetGroupBiConstraintStream, BavetJoinBiConstraintStream, BavetJoinBridgeBiConstraintStream, BavetScoringBiConstraintStream

      public abstract class BavetAbstractBiConstraintStream<Solution_,A,B>
      extends BavetAbstractConstraintStream<Solution_>
      implements InnerBiConstraintStream<A,B>

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<BavetAbstractBiConstraintStream<Solution_,A,B>>` | `childStreamList`

    - ### Fields inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream

      `constraintFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BavetAbstractBiConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)`
    `protected void` | `createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, int nodeOrder, BavetAbstractBiNode<A,B> node)`
    `protected abstract BavetAbstractBiNode<A,B>` | `createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, int nodeOrder, BavetAbstractBiNode<A,B> parentNode)`
    `BavetAbstractBiNode<A,B>` | `createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, int nodeOrder, BavetAbstractBiNode<A,B> parentNode)`
    `BavetAbstractBiConstraintStream<Solution_,A,B>` | `filter(BiPredicate<A,B> predicate)` Exhaustively test each tuple of facts against the `BiPredicate` and match if `BiPredicate.test(Object, Object)` returns true.
    `<ResultContainer_,Result_> UniConstraintStream<Result_>` | `groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)` Runs all tuples of the stream through a given @`BiConstraintCollector` and converts them into a new `UniConstraintStream` which only has a single tuple, the result of applying `BiConstraintCollector`.
    `<GroupKey_> UniConstraintStream<GroupKey_>` | `groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)` Convert the `BiConstraintStream` to a `UniConstraintStream`, containing the set of tuples resulting from applying the group key mapping function on all tuples of the original stream.
    `<GroupKey_,ResultContainer_,Result_> BiConstraintStream<GroupKey_,Result_>` | `groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)` Convert the `BiConstraintStream` to a different `BiConstraintStream`, consisting of unique tuples.
    `<GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_>` | `groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping)` Convert the `BiConstraintStream` to a different `BiConstraintStream`, consisting of unique tuples.
    `<GroupKeyA_,GroupKeyB_,ResultContainer_,Result_> TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_>` | `groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)` Combines the semantics of `BiConstraintStream.groupBy(BiFunction, BiFunction)` and `BiConstraintStream.groupBy(BiConstraintCollector)`.
    `<GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_>` | `groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)` Combines the semantics of `BiConstraintStream.groupBy(BiFunction, BiFunction)` and `BiConstraintStream.groupBy(BiConstraintCollector)`.
    `Constraint` | `impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, boolean positive)`
    `Constraint` | `impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, boolean positive)`
    `Constraint` | `impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, boolean positive)`
    `Constraint` | `impactScoreConfigurable(String constraintPackage, String constraintName, boolean positive)`
    `Constraint` | `impactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, boolean positive)`
    `Constraint` | `impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, boolean positive)`
    `Constraint` | `impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, boolean positive)`
    `Constraint` | `impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, boolean positive)`
    `<C> TriConstraintStream<A,B,C>` | `join(UniConstraintStream<C> otherStream, TriJoiner<A,B,C> joiner)` Create a new `TriConstraintStream` for every combination of [A, B] and C for which the `TriJoiner` is true (for the properties it extracts from both facts).
    `protected BavetAbstractBiNode<A,B>` | `processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, int nodeOrder, BavetAbstractBiNode<A,B> parentNode, BavetAbstractBiNode<A,B> node)`

    - ### Methods inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream

      `buildConstraint, buildConstraintConfigurable, getConstraintFactory, getFromStreamList`

    - ### Methods inherited from class org.optaplanner.core.impl.score.stream.common.AbstractConstraintStream

      `buildConstraintWeightExtractor, buildConstraintWeightExtractor, penalize, penalizeConfigurable, reward, rewardConfigurable, validateConstraintId`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.optaplanner.core.impl.score.stream.bi.InnerBiConstraintStream

      `penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong`

    - ### Methods inherited from interface org.optaplanner.core.api.score.stream.bi.BiConstraintStream

      `join, join, join, join, join, join, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong`

    - ### Methods inherited from interface org.optaplanner.core.api.score.stream.ConstraintStream

      `getConstraintFactory, penalize, penalize, penalizeConfigurable, penalizeConfigurable, reward, reward, rewardConfigurable, rewardConfigurable`

- - ### Field Detail

    - #### childStreamList

          protected final List<BavetAbstractBiConstraintStream<Solution_,A,B>> childStreamList

  - ### Constructor Detail

    - #### BavetAbstractBiConstraintStream

          public BavetAbstractBiConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)

  - ### Method Detail

    - #### addChildStream

          protected void addChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)

    - #### filter

          public BavetAbstractBiConstraintStream<Solution_,A,B> filter(BiPredicate<A,B> predicate)

      Description copied from interface: `BiConstraintStream`
      Exhaustively test each tuple of facts against the `BiPredicate` and match if `BiPredicate.test(Object, Object)` returns true.

      Important: This is slower and less scalable than `UniConstraintStream.join(UniConstraintStream, BiJoiner)` with a proper `BiJoiner` predicate (such as `Joiners.equal(Function, Function)`, because the latter applies hashing and/or indexing, so it doesn't create every combination just to filter it out.

      Specified by:
        `filter` in interface `BiConstraintStream<A,B>`
      Parameters:
        `predicate` - never null
      Returns:
        never null

    - #### join

          public <C> TriConstraintStream<A,B,C> join(UniConstraintStream<C> otherStream,
                                                     TriJoiner<A,B,C> joiner)

      Description copied from interface: `BiConstraintStream`
      Create a new `TriConstraintStream` for every combination of [A, B] and C for which the `TriJoiner` is true (for the properties it extracts from both facts).

      Important: This is faster and more scalable than a `join` followed by a `filter`, because it applies hashing and/or indexing on the properties, so it doesn't create nor checks every combination of [A, B] and C.

      Specified by:
        `join` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `C` - the type of the third matched fact
      Parameters:
        `otherStream` - never null
        `joiner` - never null
      Returns:
        a stream that matches every combination of [A, B] and C for which the `TriFunction` is true

    - #### groupBy

          public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)

      Description copied from interface: `BiConstraintStream`
      Runs all tuples of the stream through a given @`BiConstraintCollector` and converts them into a new `UniConstraintStream` which only has a single tuple, the result of applying `BiConstraintCollector`.
      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `ResultContainer_` - the mutable accumulation type (often hidden as an implementation detail)
        `Result_` - the type of a fact in the destination `UniConstraintStream`'s tuple
      Parameters:
        `collector` - never null, the collector to perform the grouping operation with
      Returns:
        never null

    - #### groupBy

          public <GroupKey_> UniConstraintStream<GroupKey_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)

      Description copied from interface: `BiConstraintStream`
      Convert the `BiConstraintStream` to a `UniConstraintStream`, containing the set of tuples resulting from applying the group key mapping function on all tuples of the original stream. Neither tuple of the new stream `Objects.equals(Object, Object)` any other.
      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `GroupKey_` - the type of a fact in the destination `UniConstraintStream`'s tuple
      Parameters:
        `groupKeyMapping` - never null, mapping function to convert each element in the stream to a different element
      Returns:
        never null

    - #### groupBy

          public <GroupKey_,ResultContainer_,Result_> BiConstraintStream<GroupKey_,Result_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping,
                                                                                                    BiConstraintCollector<A,B,ResultContainer_,Result_> collector)

      Description copied from interface: `BiConstraintStream`
      Convert the `BiConstraintStream` to a different `BiConstraintStream`, consisting of unique tuples.

      The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of a given `BiConstraintCollector` applied on all incoming tuples with the same first fact.

      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `GroupKey_` - the type of the first fact in the destination `BiConstraintStream`'s tuple
        `ResultContainer_` - the mutable accumulation type (often hidden as an implementation detail)
        `Result_` - the type of the second fact in the destination `BiConstraintStream`'s tuple
      Parameters:
        `groupKeyMapping` - never null, function to convert the fact in the original tuple to a different fact
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
                                                                                           BiFunction<A,B,GroupKeyB_> groupKeyBMapping)

      Description copied from interface: `BiConstraintStream`
      Convert the `BiConstraintStream` to a different `BiConstraintStream`, consisting of unique tuples.

      The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of the second group key mapping function, applied on all incoming tuples with the same first fact.

      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `GroupKeyA_` - the type of the first fact in the destination `BiConstraintStream`'s tuple
        `GroupKeyB_` - the type of the second fact in the destination `BiConstraintStream`'s tuple
      Parameters:
        `groupKeyAMapping` - never null, function to convert the facts in the original tuple to a new fact
        `groupKeyBMapping` - never null, function to convert the facts in the original tuple to another new fact
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,GroupKeyB_,ResultContainer_,Result_> TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
                                                                                                                             BiFunction<A,B,GroupKeyB_> groupKeyBMapping,
                                                                                                                             BiConstraintCollector<A,B,ResultContainer_,Result_> collector)

      Description copied from interface: `BiConstraintStream`
      Combines the semantics of `BiConstraintStream.groupBy(BiFunction, BiFunction)` and `BiConstraintStream.groupBy(BiConstraintCollector)`. That is, the first and second facts in the tuple follow the `BiConstraintStream.groupBy(BiFunction, BiFunction)` semantics, and the third fact is the result of applying `BiConstraintCollector.finisher()` on all the tuples of the original `UniConstraintStream` that belong to the group.
      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `GroupKeyA_` - the type of the first fact in the destination `TriConstraintStream`'s tuple
        `GroupKeyB_` - the type of the second fact in the destination `TriConstraintStream`'s tuple
        `ResultContainer_` - the mutable accumulation type (often hidden as an implementation detail)
        `Result_` - the type of the third fact in the destination `TriConstraintStream`'s tuple
      Parameters:
        `groupKeyAMapping` - never null, function to convert the original tuple into a first fact
        `groupKeyBMapping` - never null, function to convert the original tuple into a second fact
        `collector` - never null, the collector to perform the grouping operation with
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
                                                                                                                                                                     BiFunction<A,B,GroupKeyB_> groupKeyBMapping,
                                                                                                                                                                     BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC,
                                                                                                                                                                     BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)

      Description copied from interface: `BiConstraintStream`
      Combines the semantics of `BiConstraintStream.groupBy(BiFunction, BiFunction)` and `BiConstraintStream.groupBy(BiConstraintCollector)`. That is, the first and second facts in the tuple follow the `BiConstraintStream.groupBy(BiFunction, BiFunction)` semantics. The third fact is the result of applying the first `BiConstraintCollector.finisher()` on all the tuples of the original `BiConstraintStream` that belong to the group. The fourth fact is the result of applying the second `BiConstraintCollector.finisher()` on all the tuples of the original `BiConstraintStream` that belong to the group
      Specified by:
        `groupBy` in interface `BiConstraintStream<A,B>`
      Type Parameters:
        `GroupKeyA_` - the type of the first fact in the destination `QuadConstraintStream`'s tuple
        `GroupKeyB_` - the type of the second fact in the destination `QuadConstraintStream`'s tuple
        `ResultContainerC_` - the mutable accumulation type (often hidden as an implementation detail)
        `ResultC_` - the type of the third fact in the destination `QuadConstraintStream`'s tuple
        `ResultContainerD_` - the mutable accumulation type (often hidden as an implementation detail)
        `ResultD_` - the type of the fourth fact in the destination `QuadConstraintStream`'s tuple
      Parameters:
        `groupKeyAMapping` - never null, function to convert the original tuple into a first fact
        `groupKeyBMapping` - never null, function to convert the original tuple into a second fact
        `collectorC` - never null, the collector to perform the first grouping operation with
        `collectorD` - never null, the collector to perform the first grouping operation with
      Returns:
        never null

    - #### impactScore

          public final Constraint impactScore(String constraintPackage,
                                              String constraintName,
                                              Score<?> constraintWeight,
                                              boolean positive)

      Specified by:
        `impactScore` in class `AbstractConstraintStream<Solution_>`

    - #### impactScore

          public final Constraint impactScore(String constraintPackage,
                                              String constraintName,
                                              Score<?> constraintWeight,
                                              ToIntBiFunction<A,B> matchWeigher,
                                              boolean positive)

      Specified by:
        `impactScore` in interface `InnerBiConstraintStream<A,B>`

    - #### impactScoreLong

          public final Constraint impactScoreLong(String constraintPackage,
                                                  String constraintName,
                                                  Score<?> constraintWeight,
                                                  ToLongBiFunction<A,B> matchWeigher,
                                                  boolean positive)

      Specified by:
        `impactScoreLong` in interface `InnerBiConstraintStream<A,B>`

    - #### impactScoreBigDecimal

          public final Constraint impactScoreBigDecimal(String constraintPackage,
                                                        String constraintName,
                                                        Score<?> constraintWeight,
                                                        BiFunction<A,B,BigDecimal> matchWeigher,
                                                        boolean positive)

      Specified by:
        `impactScoreBigDecimal` in interface `InnerBiConstraintStream<A,B>`

    - #### impactScoreConfigurable

          public final Constraint impactScoreConfigurable(String constraintPackage,
                                                          String constraintName,
                                                          boolean positive)

      Specified by:
        `impactScoreConfigurable` in class `AbstractConstraintStream<Solution_>`

    - #### impactScoreConfigurable

          public final Constraint impactScoreConfigurable(String constraintPackage,
                                                          String constraintName,
                                                          ToIntBiFunction<A,B> matchWeigher,
                                                          boolean positive)

      Specified by:
        `impactScoreConfigurable` in interface `InnerBiConstraintStream<A,B>`

    - #### impactScoreConfigurableLong

          public final Constraint impactScoreConfigurableLong(String constraintPackage,
                                                              String constraintName,
                                                              ToLongBiFunction<A,B> matchWeigher,
                                                              boolean positive)

      Specified by:
        `impactScoreConfigurableLong` in interface `InnerBiConstraintStream<A,B>`

    - #### impactScoreConfigurableBigDecimal

          public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage,
                                                                    String constraintName,
                                                                    BiFunction<A,B,BigDecimal> matchWeigher,
                                                                    boolean positive)

      Specified by:
        `impactScoreConfigurableBigDecimal` in interface `InnerBiConstraintStream<A,B>`

    - #### createNodeChain

          public BavetAbstractBiNode<A,B> createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy,
                                                          Score<?> constraintWeight,
                                                          int nodeOrder,
                                                          BavetAbstractBiNode<A,B> parentNode)

    - #### processNode

          protected BavetAbstractBiNode<A,B> processNode(BavetNodeBuildPolicy<Solution_> buildPolicy,
                                                         int nodeOrder,
                                                         BavetAbstractBiNode<A,B> parentNode,
                                                         BavetAbstractBiNode<A,B> node)

    - #### createChildNodeChains

          protected void createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy,
                                               Score<?> constraintWeight,
                                               int nodeOrder,
                                               BavetAbstractBiNode<A,B> node)

    - #### createNode

          protected abstract BavetAbstractBiNode<A,B> createNode(BavetNodeBuildPolicy<Solution_> buildPolicy,
                                                                 Score<?> constraintWeight,
                                                                 int nodeOrder,
                                                                 BavetAbstractBiNode<A,B> parentNode)

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