Class BiLeftHandSide<A,​B>

  • Type Parameters:
    A - generic type of the first resulting variable
    B - generic type of the second resulting variable

    public final class BiLeftHandSide<A,​B>
    extends Object
    Represents the left hand side of a Drools rule, the result of which are two variables. The simplest variant of such rule, with no filters or groupBys applied, would look like this in equivalent DRL:
     
      rule "Simplest bivariate rule"
      when
          $a: Something()
          $b: SomethingElse()
      then
          // Do something with the $a and $b variables.
      end
     
     
    Usually though, there would be a joiner between the two, limiting the cartesian product:
     
      rule "Bivariate join rule"
      when
          $a: Something($leftJoin: someValue)
          $b: SomethingElse(someOtherValue == $leftJoin)
      then
          // Do something with the $a and $b variables.
      end
     
     
    For more, see UniLeftHandSide.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <C> BiLeftHandSide<A,​B> andExists​(Class<C> cClass, org.optaplanner.core.api.score.stream.tri.TriJoiner<A,​B,​C>[] joiners, Predicate<C> nullityFilter)  
      BiLeftHandSide<A,​B> andFilter​(BiPredicate<A,​B> predicate)  
      <NewB> BiLeftHandSide<A,​NewB> andFlattenLast​(Function<B,​Iterable<NewB>> mapping)  
      <NewA> UniLeftHandSide<NewA> andGroupBy​(BiFunction<A,​B,​NewA> keyMapping)  
      <NewA,​NewB>
      BiLeftHandSide<NewA,​NewB>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB)  
      <NewA,​NewB,​NewC>
      TriLeftHandSide<NewA,​NewB,​NewC>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB, BiFunction<A,​B,​NewC> keyMappingC)  
      <NewA,​NewB,​NewC,​NewD>
      QuadLeftHandSide<NewA,​NewB,​NewC,​NewD>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB, BiFunction<A,​B,​NewC> keyMappingC, BiFunction<A,​B,​NewD> keyMappingD)  
      <NewA,​NewB,​NewC,​NewD>
      QuadLeftHandSide<NewA,​NewB,​NewC,​NewD>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB, BiFunction<A,​B,​NewC> keyMappingC, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)  
      <NewA,​NewB,​NewC>
      TriLeftHandSide<NewA,​NewB,​NewC>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)  
      <NewA,​NewB,​NewC,​NewD>
      QuadLeftHandSide<NewA,​NewB,​NewC,​NewD>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, BiFunction<A,​B,​NewB> keyMappingB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)  
      <NewA,​NewB>
      BiLeftHandSide<NewA,​NewB>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB)  
      <NewA,​NewB,​NewC>
      TriLeftHandSide<NewA,​NewB,​NewC>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)  
      <NewA,​NewB,​NewC,​NewD>
      QuadLeftHandSide<NewA,​NewB,​NewC,​NewD>
      andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)  
      <NewA> UniLeftHandSide<NewA> andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collector)  
      <NewA,​NewB>
      BiLeftHandSide<NewA,​NewB>
      andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB)  
      <NewA,​NewB,​NewC>
      TriLeftHandSide<NewA,​NewB,​NewC>
      andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)  
      <NewA,​NewB,​NewC,​NewD>
      QuadLeftHandSide<NewA,​NewB,​NewC,​NewD>
      andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC, org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)  
      <C> TriLeftHandSide<A,​B,​C> andJoin​(UniLeftHandSide<C> right, org.optaplanner.core.api.score.stream.tri.TriJoiner<A,​B,​C> joiner)  
      <NewA> UniLeftHandSide<NewA> andMap​(BiFunction<A,​B,​NewA> mapping)  
      <C> BiLeftHandSide<A,​B> andNotExists​(Class<C> cClass, org.optaplanner.core.api.score.stream.tri.TriJoiner<A,​B,​C>[] joiners, Predicate<C> nullityFilter)  
      <Solution_>
      RuleBuilder<Solution_>
      andTerminate()  
      <Solution_>
      RuleBuilder<Solution_>
      andTerminate​(BiFunction<A,​B,​BigDecimal> matchWeighter)  
      <Solution_>
      RuleBuilder<Solution_>
      andTerminate​(ToIntBiFunction<A,​B> matchWeighter)  
      <Solution_>
      RuleBuilder<Solution_>
      andTerminate​(ToLongBiFunction<A,​B> matchWeighter)  
      protected static org.drools.model.view.ViewItem<?> buildAccumulate​(org.drools.model.view.ViewItem<?> innerAccumulatePattern, org.drools.model.functions.accumulate.AccumulateFunction... accFunctions)  
      protected static <A,​B>
      org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<B,​BiTuple<A,​B>>
      decompose​(org.drools.model.Variable<BiTuple<A,​B>> primaryVariable, org.drools.model.view.ViewItem<?> prerequisitePattern, org.drools.model.Variable<A> boundVarA, org.drools.model.Variable<B> boundVarB)
      Create an IndirectPatternVariable on BiTuple with pre-made bindings for its components variables.
      protected static <A,​B,​C,​D>
      org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<D,​QuadTuple<A,​B,​C,​D>>
      decompose​(org.drools.model.Variable<QuadTuple<A,​B,​C,​D>> primaryVariable, org.drools.model.view.ViewItem<?> prerequisitePattern, org.drools.model.Variable<A> boundVarA, org.drools.model.Variable<B> boundVarB, org.drools.model.Variable<C> boundVarC, org.drools.model.Variable<D> boundVarD)
      Create an IndirectPatternVariable on QuadTuple with pre-made bindings for its components variables.
      protected static <A,​B,​C>
      org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<C,​TriTuple<A,​B,​C>>
      decompose​(org.drools.model.Variable<TriTuple<A,​B,​C>> primaryVariable, org.drools.model.view.ViewItem<?> prerequisitePattern, org.drools.model.Variable<A> boundVarA, org.drools.model.Variable<B> boundVarB, org.drools.model.Variable<C> boundVarC)
      Create an IndirectPatternVariable on TriTuple with pre-made bindings for its components variables.
      protected static <A,​B,​C>
      org.optaplanner.constraint.streams.drools.common.DirectPatternVariable<C>
      decomposeWithAccumulate​(org.drools.model.Variable<BiTuple<A,​B>> primaryVariable, org.drools.model.view.ViewItem<?> prerequisitePattern, org.drools.model.Variable<A> boundVarA, org.drools.model.Variable<B> boundVarB, org.drools.model.Variable<C> accumulateOutput)
      Create a DirectPatternVariable on BiTuple with pre-made bindings for its components variables and one accumulate output variable.
      protected static <A,​B,​C,​D>
      org.optaplanner.constraint.streams.drools.common.DirectPatternVariable<D>
      decomposeWithAccumulate​(org.drools.model.Variable<TriTuple<A,​B,​C>> primaryVariable, org.drools.model.view.ViewItem<?> prerequisitePattern, org.drools.model.Variable<A> boundVarA, org.drools.model.Variable<B> boundVarB, org.drools.model.Variable<C> boundVarC, org.drools.model.Variable<D> accumulateOutput)
      Create a DirectPatternVariable on TriTuple with pre-made bindings for its components variables and one accumulate output variable.
      protected static org.drools.model.Index.ConstraintType getConstraintType​(org.optaplanner.core.impl.score.stream.JoinerType type)  
      protected static org.drools.model.view.ViewItem<?> joinViewItemsWithLogicalAnd​(PatternVariable<?,​?,​?>... patternVariables)  
      protected static List<org.drools.model.view.ViewItem<?>> mergeViewItems​(PatternVariable<?,​?,​?>... patternVariables)  
    • Method Detail

      • andExists

        public <C> BiLeftHandSide<A,​B> andExists​(Class<C> cClass,
                                                       org.optaplanner.core.api.score.stream.tri.TriJoiner<A,​B,​C>[] joiners,
                                                       Predicate<C> nullityFilter)
      • andNotExists

        public <C> BiLeftHandSide<A,​B> andNotExists​(Class<C> cClass,
                                                          org.optaplanner.core.api.score.stream.tri.TriJoiner<A,​B,​C>[] joiners,
                                                          Predicate<C> nullityFilter)
      • andGroupBy

        public <NewA> UniLeftHandSide<NewA> andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collector)
      • andGroupBy

        public <NewA,​NewB> BiLeftHandSide<NewA,​NewB> andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA,
                                                                            org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB)
      • andGroupBy

        public <NewA,​NewB,​NewC> TriLeftHandSide<NewA,​NewB,​NewC> andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA,
                                                                                                   org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB,
                                                                                                   org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)
      • andGroupBy

        public <NewA,​NewB,​NewC,​NewD> QuadLeftHandSide<NewA,​NewB,​NewC,​NewD> andGroupBy​(org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewA> collectorA,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)
      • andGroupBy

        public <NewA,​NewB> BiLeftHandSide<NewA,​NewB> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                            org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB)
      • andGroupBy

        public <NewA,​NewB,​NewC> TriLeftHandSide<NewA,​NewB,​NewC> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                                                   org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB,
                                                                                                   org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)
      • andGroupBy

        public <NewA,​NewB,​NewC,​NewD> QuadLeftHandSide<NewA,​NewB,​NewC,​NewD> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewB> collectorB,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)
      • andGroupBy

        public <NewA,​NewB,​NewC> TriLeftHandSide<NewA,​NewB,​NewC> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                                                   BiFunction<A,​B,​NewB> keyMappingB,
                                                                                                   org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC)
      • andGroupBy

        public <NewA,​NewB,​NewC,​NewD> QuadLeftHandSide<NewA,​NewB,​NewC,​NewD> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                                                                          BiFunction<A,​B,​NewB> keyMappingB,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewC> collectorC,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)
      • andGroupBy

        public <NewA,​NewB,​NewC,​NewD> QuadLeftHandSide<NewA,​NewB,​NewC,​NewD> andGroupBy​(BiFunction<A,​B,​NewA> keyMappingA,
                                                                                                                          BiFunction<A,​B,​NewB> keyMappingB,
                                                                                                                          BiFunction<A,​B,​NewC> keyMappingC,
                                                                                                                          org.optaplanner.core.api.score.stream.bi.BiConstraintCollector<A,​B,​?,​NewD> collectorD)
      • andTerminate

        public <Solution_> RuleBuilder<Solution_> andTerminate()
      • getConstraintType

        protected static org.drools.model.Index.ConstraintType getConstraintType​(org.optaplanner.core.impl.score.stream.JoinerType type)
      • joinViewItemsWithLogicalAnd

        protected static org.drools.model.view.ViewItem<?> joinViewItemsWithLogicalAnd​(PatternVariable<?,​?,​?>... patternVariables)
      • mergeViewItems

        protected static List<org.drools.model.view.ViewItem<?>> mergeViewItems​(PatternVariable<?,​?,​?>... patternVariables)
      • decompose

        protected static <A,​B> org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<B,​BiTuple<A,​B>> decompose​(org.drools.model.Variable<BiTuple<A,​B>> primaryVariable,
                                                                                                                                                    org.drools.model.view.ViewItem<?> prerequisitePattern,
                                                                                                                                                    org.drools.model.Variable<A> boundVarA,
                                                                                                                                                    org.drools.model.Variable<B> boundVarB)
        Create an IndirectPatternVariable on BiTuple with pre-made bindings for its components variables.
        Type Parameters:
        A - generic type of the first bound variable
        B - generic type of the second bound variable
        Parameters:
        primaryVariable - never null
        prerequisitePattern - never null, pattern required to construct the variable
        boundVarA - never null, BiTuple.a
        boundVarB - never null, BiTuple.b
        Returns:
        never null
      • decomposeWithAccumulate

        protected static <A,​B,​C> org.optaplanner.constraint.streams.drools.common.DirectPatternVariable<C> decomposeWithAccumulate​(org.drools.model.Variable<BiTuple<A,​B>> primaryVariable,
                                                                                                                                               org.drools.model.view.ViewItem<?> prerequisitePattern,
                                                                                                                                               org.drools.model.Variable<A> boundVarA,
                                                                                                                                               org.drools.model.Variable<B> boundVarB,
                                                                                                                                               org.drools.model.Variable<C> accumulateOutput)
        Create a DirectPatternVariable on BiTuple with pre-made bindings for its components variables and one accumulate output variable.
        Type Parameters:
        A - generic type of the first bound variable
        B - generic type of the second bound variable
        C - generic type of the accumulate output variable
        Parameters:
        primaryVariable - never null
        prerequisitePattern - never null, pattern required to construct the variable
        boundVarA - never null, TriTuple.a
        boundVarB - never null, TriTuple.b
        accumulateOutput - never null, output of the accumulate function
        Returns:
        never null
      • decompose

        protected static <A,​B,​C> org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<C,​TriTuple<A,​B,​C>> decompose​(org.drools.model.Variable<TriTuple<A,​B,​C>> primaryVariable,
                                                                                                                                                                     org.drools.model.view.ViewItem<?> prerequisitePattern,
                                                                                                                                                                     org.drools.model.Variable<A> boundVarA,
                                                                                                                                                                     org.drools.model.Variable<B> boundVarB,
                                                                                                                                                                     org.drools.model.Variable<C> boundVarC)
        Create an IndirectPatternVariable on TriTuple with pre-made bindings for its components variables.
        Type Parameters:
        A - generic type of the first bound variable
        B - generic type of the second bound variable
        C - generic type of the third bound variable
        Parameters:
        primaryVariable - never null
        prerequisitePattern - never null, pattern required to construct the variable
        boundVarA - never null, TriTuple.a
        boundVarB - never null, TriTuple.b
        boundVarC - never null, TriTuple.c
        Returns:
        never null
      • decompose

        protected static <A,​B,​C,​D> org.optaplanner.constraint.streams.drools.common.IndirectPatternVariable<D,​QuadTuple<A,​B,​C,​D>> decompose​(org.drools.model.Variable<QuadTuple<A,​B,​C,​D>> primaryVariable,
                                                                                                                                                                                      org.drools.model.view.ViewItem<?> prerequisitePattern,
                                                                                                                                                                                      org.drools.model.Variable<A> boundVarA,
                                                                                                                                                                                      org.drools.model.Variable<B> boundVarB,
                                                                                                                                                                                      org.drools.model.Variable<C> boundVarC,
                                                                                                                                                                                      org.drools.model.Variable<D> boundVarD)
        Create an IndirectPatternVariable on QuadTuple with pre-made bindings for its components variables.
        Type Parameters:
        A - generic type of the first bound variable
        B - generic type of the second bound variable
        C - generic type of the third bound variable
        D - generic type of the fourth bound variable
        Parameters:
        primaryVariable - never null
        prerequisitePattern - never null, pattern required to construct the variable
        boundVarA - never null, QuadTuple.a
        boundVarB - never null, QuadTuple.b
        boundVarC - never null, QuadTuple.c
        boundVarD - never null, QuadTuple.d
        Returns:
        never null
      • decomposeWithAccumulate

        protected static <A,​B,​C,​D> org.optaplanner.constraint.streams.drools.common.DirectPatternVariable<D> decomposeWithAccumulate​(org.drools.model.Variable<TriTuple<A,​B,​C>> primaryVariable,
                                                                                                                                                       org.drools.model.view.ViewItem<?> prerequisitePattern,
                                                                                                                                                       org.drools.model.Variable<A> boundVarA,
                                                                                                                                                       org.drools.model.Variable<B> boundVarB,
                                                                                                                                                       org.drools.model.Variable<C> boundVarC,
                                                                                                                                                       org.drools.model.Variable<D> accumulateOutput)
        Create a DirectPatternVariable on TriTuple with pre-made bindings for its components variables and one accumulate output variable.
        Type Parameters:
        A - generic type of the first bound variable
        B - generic type of the second bound variable
        C - generic type of the third bound variable
        D - generic type of the accumulate output variable
        Parameters:
        primaryVariable - never null
        prerequisitePattern - never null, pattern required to construct the variable
        boundVarA - never null, TriTuple.a
        boundVarB - never null, TriTuple.b
        boundVarC - never null, TriTuple.c
        accumulateOutput - never null, output of the accumulate function
        Returns:
        never null
      • buildAccumulate

        protected static org.drools.model.view.ViewItem<?> buildAccumulate​(org.drools.model.view.ViewItem<?> innerAccumulatePattern,
                                                                           org.drools.model.functions.accumulate.AccumulateFunction... accFunctions)