Package org.optaplanner.core.impl.score.stream.drools.uni

## Class DroolsAbstractUniConstraintStream<Solution_,​A>

- java.lang.Object
- - org.optaplanner.core.impl.score.stream.common.AbstractConstraintStream<Solution_>
  - - org.optaplanner.core.impl.score.stream.drools.common.DroolsAbstractConstraintStream<Solution_>
    - - org.optaplanner.core.impl.score.stream.drools.uni.DroolsAbstractUniConstraintStream<Solution_,​A>

- All Implemented Interfaces:
    `ConstraintStream`, `UniConstraintStream<A>`, `InnerUniConstraintStream<A>`
  Direct Known Subclasses:
    `DroolsExistsUniConstraintStream`, `DroolsFilterUniConstraintStream`, `DroolsFromUniConstraintStream`, `DroolsGroupingUniConstraintStream`, `DroolsScoringUniConstraintStream`

      public abstract class DroolsAbstractUniConstraintStream<Solution_,​A>
      extends DroolsAbstractConstraintStream<Solution_>
      implements InnerUniConstraintStream<A>

- - ### Field Summary

    - ### Fields inherited from class org.optaplanner.core.impl.score.stream.drools.common.DroolsAbstractConstraintStream

      `constraintFactory`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DroolsAbstractUniConstraintStream​(DroolsConstraintFactory<Solution_> constraintFactory)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `UniConstraintStream<A>` | `filter​(Predicate<A> predicate)` | Exhaustively test each fact against the `Predicate` and match if `Predicate.test(Object)` returns true.
    `int` | `getCardinality()` |
    `abstract DroolsUniCondition<A,​?>` | `getCondition()` |
    `<GroupKey_> UniConstraintStream<GroupKey_>` | `groupBy​(Function<A,​GroupKey_> groupKeyMapping)` | Convert the `UniConstraintStream` to a different `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​(Function<A,​GroupKey_> groupKeyMapping, UniConstraintCollector<A,​ResultContainer_,​Result_> collector)` | Convert the `UniConstraintStream` to a `BiConstraintStream`, consisting of unique tuples with two facts.
    `<GroupKeyA_,​GroupKeyB_> BiConstraintStream<GroupKeyA_,​GroupKeyB_>` | `groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping, Function<A,​GroupKeyB_> groupKeyBMapping)` | Convert the `UniConstraintStream` to a `BiConstraintStream`, consisting of unique tuples with two facts.
    `<GroupKeyA_,​GroupKeyB_,​ResultContainer_,​Result_> TriConstraintStream<GroupKeyA_,​GroupKeyB_,​Result_>` | `groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping, Function<A,​GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,​ResultContainer_,​Result_> collector)` | Combines the semantics of `UniConstraintStream.groupBy(Function, Function)` and `UniConstraintStream.groupBy(UniConstraintCollector)`.
    `<GroupKeyA_,​GroupKeyB_,​ResultContainerC_,​ResultC_,​ResultContainerD_,​ResultD_> QuadConstraintStream<GroupKeyA_,​GroupKeyB_,​ResultC_,​ResultD_>` | `groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping, Function<A,​GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,​ResultContainerC_,​ResultC_> collectorC, UniConstraintCollector<A,​ResultContainerD_,​ResultD_> collectorD)` | Combines the semantics of `UniConstraintStream.groupBy(Function, Function)` and `UniConstraintStream.groupBy(UniConstraintCollector)`.
    `<ResultContainer_,​Result_> UniConstraintStream<Result_>` | `groupBy​(UniConstraintCollector<A,​ResultContainer_,​Result_> collector)` | Convert the `UniConstraintStream` to a different `UniConstraintStream`, containing only a single tuple, the result of applying `UniConstraintCollector`.
    `<B> UniConstraintStream<A>` | `ifExists​(Class<B> otherClass, BiJoiner<A,​B>... joiners)` | As defined by `UniConstraintStream.ifExists(Class, BiJoiner)`.
    `<B> UniConstraintStream<A>` | `ifNotExists​(Class<B> otherClass, BiJoiner<A,​B>... joiners)` | As defined by `UniConstraintStream.ifNotExists(Class, BiJoiner)`.
    `Constraint` | `impactScore​(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)` |
    `Constraint` | `impactScore​(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreBigDecimal​(String constraintPackage, String constraintName, Score<?> constraintWeight, Function<A,​BigDecimal> matchWeigher, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreConfigurable​(String constraintPackage, String constraintName, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreConfigurable​(String constraintPackage, String constraintName, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreConfigurableBigDecimal​(String constraintPackage, String constraintName, Function<A,​BigDecimal> matchWeigher, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreConfigurableLong​(String constraintPackage, String constraintName, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)` |
    `Constraint` | `impactScoreLong​(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)` |
    `<B> BiConstraintStream<A,​B>` | `join​(UniConstraintStream<B> otherStream, BiJoiner<A,​B> joiner)` | Create a new `BiConstraintStream` for every combination of A and B for which the `BiJoiner` is true (for the properties it extracts from both facts).

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

      `addChildStream, buildConstraint, buildConstraintConfigurable, createRuleItemBuilders, getChildStreams, getConstraintFactory, getExpectedJustificationTypes, getFromStreamList`

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

      `buildConstraintWeightExtractor, buildConstraintWeightExtractor, impact, penalize, penalizeConfigurable, reward, rewardConfigurable`

    - ### 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.api.score.stream.ConstraintStream

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

    - ### Methods inherited from interface org.optaplanner.core.impl.score.stream.uni.InnerUniConstraintStream

      `impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong`

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

      `ifExists, ifExists, ifExists, ifExists, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifNotExists, ifNotExists, ifNotExists, ifNotExists, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, join, join, join, join, join, join, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong`

- - ### Constructor Detail

    - #### DroolsAbstractUniConstraintStream

          public DroolsAbstractUniConstraintStream​(DroolsConstraintFactory<Solution_> constraintFactory)

  - ### Method Detail

    - #### getCardinality

          public int getCardinality()

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

    - #### filter

          public UniConstraintStream<A> filter​(Predicate<A> predicate)

      Description copied from interface: `UniConstraintStream`
      Exhaustively test each fact against the `Predicate` and match if `Predicate.test(Object)` returns true.
      Specified by:
        `filter` in interface `UniConstraintStream<Solution_>`
      Parameters:
        `predicate` - never null
      Returns:
        never null

    - #### join

          public <B> BiConstraintStream<A,​B> join​(UniConstraintStream<B> otherStream,
                                                        BiJoiner<A,​B> joiner)

      Description copied from interface: `UniConstraintStream`
      Create a new `BiConstraintStream` for every combination of A and B for which the `BiJoiner` 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 and B.

      Specified by:
        `join` in interface `UniConstraintStream<Solution_>`
      Type Parameters:
        `B` - the type of the second matched fact
      Parameters:
        `otherStream` - never null
        `joiner` - never null
      Returns:
        never null, a stream that matches every combination of A and B for which the `BiJoiner` is true

    - #### ifExists

          @SafeVarargs
          public final <B> UniConstraintStream<A> ifExists​(Class<B> otherClass,
                                                           BiJoiner<A,​B>... joiners)

      Description copied from interface: `UniConstraintStream`
      As defined by `UniConstraintStream.ifExists(Class, BiJoiner)`. For performance reasons, indexing joiners must be placed before filtering joiners.

      This method causes Unchecked generics array creation for varargs parameter warnings, but we can't fix it with a `SafeVarargs` annotation because it's an interface method. Therefore, there are overloaded methods with up to 4 `BiJoiner` parameters.

      Specified by:
        `ifExists` in interface `UniConstraintStream<Solution_>`
      Type Parameters:
        `B` - the type of the second matched fact
      Parameters:
        `otherClass` - never null
        `joiners` - never null
      Returns:
        never null, a stream that matches every A where B exists for which all the `BiJoiner`s are true

    - #### ifNotExists

          @SafeVarargs
          public final <B> UniConstraintStream<A> ifNotExists​(Class<B> otherClass,
                                                              BiJoiner<A,​B>... joiners)

      Description copied from interface: `UniConstraintStream`
      As defined by `UniConstraintStream.ifNotExists(Class, BiJoiner)`. For performance reasons, indexing joiners must be placed before filtering joiners.

      This method causes Unchecked generics array creation for varargs parameter warnings, but we can't fix it with a `SafeVarargs` annotation because it's an interface method. Therefore, there are overloaded methods with up to 4 `BiJoiner` parameters.

      Specified by:
        `ifNotExists` in interface `UniConstraintStream<Solution_>`
      Type Parameters:
        `B` - the type of the second matched fact
      Parameters:
        `otherClass` - never null
        `joiners` - never null
      Returns:
        never null, a stream that matches every A where B does not exist for which all the `BiJoiner`s are true

    - #### groupBy

          public <ResultContainer_,​Result_> UniConstraintStream<Result_> groupBy​(UniConstraintCollector<A,​ResultContainer_,​Result_> collector)

      Description copied from interface: `UniConstraintStream`
      Convert the `UniConstraintStream` to a different `UniConstraintStream`, containing only a single tuple, the result of applying `UniConstraintCollector`.
      Specified by:
        `groupBy` in interface `UniConstraintStream<Solution_>`
      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 See `ConstraintCollectors` for common operations, such as `count()`, `sum()` and others.
      Returns:
        never null

    - #### groupBy

          public <GroupKey_> UniConstraintStream<GroupKey_> groupBy​(Function<A,​GroupKey_> groupKeyMapping)

      Description copied from interface: `UniConstraintStream`
      Convert the `UniConstraintStream` to a different `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 `UniConstraintStream<Solution_>`
      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​(Function<A,​GroupKey_> groupKeyMapping,
                                                                                                                      UniConstraintCollector<A,​ResultContainer_,​Result_> collector)

      Description copied from interface: `UniConstraintStream`
      Convert the `UniConstraintStream` to a `BiConstraintStream`, consisting of unique tuples with two facts.

      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 `UniConstraintCollector` applied on all incoming tuples with the same first fact.

      Specified by:
        `groupBy` in interface `UniConstraintStream<Solution_>`
      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
        `collector` - never null, the collector to perform the grouping operation with See `ConstraintCollectors` for common operations, such as `count()`, `sum()` and others.
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,​GroupKeyB_> BiConstraintStream<GroupKeyA_,​GroupKeyB_> groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping,
                                                                                                       Function<A,​GroupKeyB_> groupKeyBMapping)

      Description copied from interface: `UniConstraintStream`
      Convert the `UniConstraintStream` to a `BiConstraintStream`, consisting of unique tuples with two facts.

      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 `UniConstraintStream<Solution_>`
      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 original tuple into a first fact
        `groupKeyBMapping` - never null, function to convert the original tuple into a second fact
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,​GroupKeyB_,​ResultContainer_,​Result_> TriConstraintStream<GroupKeyA_,​GroupKeyB_,​Result_> groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping,
                                                                                                                                                           Function<A,​GroupKeyB_> groupKeyBMapping,
                                                                                                                                                           UniConstraintCollector<A,​ResultContainer_,​Result_> collector)

      Description copied from interface: `UniConstraintStream`
      Combines the semantics of `UniConstraintStream.groupBy(Function, Function)` and `UniConstraintStream.groupBy(UniConstraintCollector)`. That is, the first and second facts in the tuple follow the `UniConstraintStream.groupBy(Function, Function)` semantics, and the third fact is the result of applying `UniConstraintCollector.finisher()` on all the tuples of the original `UniConstraintStream` that belong to the group.
      Specified by:
        `groupBy` in interface `UniConstraintStream<Solution_>`
      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 See `ConstraintCollectors` for common operations, such as `count()`, `sum()` and others.
      Returns:
        never null

    - #### groupBy

          public <GroupKeyA_,​GroupKeyB_,​ResultContainerC_,​ResultC_,​ResultContainerD_,​ResultD_> QuadConstraintStream<GroupKeyA_,​GroupKeyB_,​ResultC_,​ResultD_> groupBy​(Function<A,​GroupKeyA_> groupKeyAMapping,
                                                                                                                                                                                                                     Function<A,​GroupKeyB_> groupKeyBMapping,
                                                                                                                                                                                                                     UniConstraintCollector<A,​ResultContainerC_,​ResultC_> collectorC,
                                                                                                                                                                                                                     UniConstraintCollector<A,​ResultContainerD_,​ResultD_> collectorD)

      Description copied from interface: `UniConstraintStream`
      Combines the semantics of `UniConstraintStream.groupBy(Function, Function)` and `UniConstraintStream.groupBy(UniConstraintCollector)`. That is, the first and second facts in the tuple follow the `UniConstraintStream.groupBy(Function, Function)` semantics. The third fact is the result of applying the first `UniConstraintCollector.finisher()` on all the tuples of the original `UniConstraintStream` that belong to the group. The fourth fact is the result of applying the second `UniConstraintCollector.finisher()` on all the tuples of the original `UniConstraintStream` that belong to the group
      Specified by:
        `groupBy` in interface `UniConstraintStream<Solution_>`
      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 See `ConstraintCollectors` for common operations, such as `count()`, `sum()` and others.
        `collectorD` - never null, the collector to perform the second grouping operation with See `ConstraintCollectors` for common operations, such as `count()`, `sum()` and others.
      Returns:
        never null

    - #### impactScore

          public final Constraint impactScore​(String constraintPackage,
                                              String constraintName,
                                              Score<?> constraintWeight,
                                              ScoreImpactType impactType)

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

    - #### impactScore

          public final Constraint impactScore​(String constraintPackage,
                                              String constraintName,
                                              Score<?> constraintWeight,
                                              ToIntFunction<A> matchWeigher,
                                              ScoreImpactType impactType)

      Specified by:
        `impactScore` in interface `InnerUniConstraintStream<Solution_>`

    - #### impactScoreLong

          public final Constraint impactScoreLong​(String constraintPackage,
                                                  String constraintName,
                                                  Score<?> constraintWeight,
                                                  ToLongFunction<A> matchWeigher,
                                                  ScoreImpactType impactType)

      Specified by:
        `impactScoreLong` in interface `InnerUniConstraintStream<Solution_>`

    - #### impactScoreBigDecimal

          public final Constraint impactScoreBigDecimal​(String constraintPackage,
                                                        String constraintName,
                                                        Score<?> constraintWeight,
                                                        Function<A,​BigDecimal> matchWeigher,
                                                        ScoreImpactType impactType)

      Specified by:
        `impactScoreBigDecimal` in interface `InnerUniConstraintStream<Solution_>`

    - #### impactScoreConfigurable

          public final Constraint impactScoreConfigurable​(String constraintPackage,
                                                          String constraintName,
                                                          ScoreImpactType impactType)

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

    - #### impactScoreConfigurable

          public final Constraint impactScoreConfigurable​(String constraintPackage,
                                                          String constraintName,
                                                          ToIntFunction<A> matchWeigher,
                                                          ScoreImpactType impactType)

      Specified by:
        `impactScoreConfigurable` in interface `InnerUniConstraintStream<Solution_>`

    - #### impactScoreConfigurableLong

          public final Constraint impactScoreConfigurableLong​(String constraintPackage,
                                                              String constraintName,
                                                              ToLongFunction<A> matchWeigher,
                                                              ScoreImpactType impactType)

      Specified by:
        `impactScoreConfigurableLong` in interface `InnerUniConstraintStream<Solution_>`

    - #### impactScoreConfigurableBigDecimal

          public final Constraint impactScoreConfigurableBigDecimal​(String constraintPackage,
                                                                    String constraintName,
                                                                    Function<A,​BigDecimal> matchWeigher,
                                                                    ScoreImpactType impactType)

      Specified by:
        `impactScoreConfigurableBigDecimal` in interface `InnerUniConstraintStream<Solution_>`

    - #### getCondition

          public abstract DroolsUniCondition<A,​?> getCondition()