Class UniLeftHandSide<A>
- java.lang.Object
-
- org.optaplanner.core.impl.score.stream.drools.common.UniLeftHandSide<A>
-
- Type Parameters:
A
- generic type of the resulting variable
public final class UniLeftHandSide<A> extends Object
Represents the left-hand side of a Drools rule, the result of which is a single variable. The simplest variant of such rule, with no filters or groupBys applied, would look like this in equivalent DRL:rule "Simplest univariate rule" when $a: Something() then // Do something with the $a variable. end
andTerminate()
. There are also more complex variants of rules that still result in just one variable:rule "Complex univariate rule" when $accumulateResult: Collection() from accumulate( ... ) $a: Object() from $accumulateResult exists Something() then // Do something with the $a variable. end
UniLeftHandSide(Class, DroolsVariableFactory)
. Further specializations can be introduced by calling builder methods such asandFilter(Predicate)
. These builder methods will always return a new instance ofAbstractLeftHandSide
, as these are immutable. Some builder methods, such asandJoin(UniLeftHandSide, BiJoiner)
, will return an instance ofBiLeftHandSide
(TriLeftHandSide
, ...), as that particular operation will increase the cardinality of the parent constraint stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected DroolsVariableFactory
variableFactory
-
Constructor Summary
Constructors Modifier Constructor Description UniLeftHandSide(Class<A> aClass, DroolsVariableFactory variableFactory)
protected
UniLeftHandSide(org.drools.model.Variable<A> variable, List<org.drools.model.view.ViewItem<?>> viewItems, DroolsVariableFactory variableFactory)
protected
UniLeftHandSide(PatternVariable<A,?,?> patternVariable, DroolsVariableFactory variableFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B> UniLeftHandSide<A>
andExists(Class<B> bClass, BiJoiner<A,B>[] joiners, Predicate<B> nullityFilter)
UniLeftHandSide<A>
andFilter(Predicate<A> predicate)
<NewA> UniLeftHandSide<NewA>
andFlattenLast(Function<A,Iterable<NewA>> mapping)
<NewA> UniLeftHandSide<NewA>
andGroupBy(Function<A,NewA> keyMapping)
<NewA,NewB>
BiLeftHandSide<NewA,NewB>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB)
<NewA,NewB,NewC>
TriLeftHandSide<NewA,NewB,NewC>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC)
<NewA,NewB,NewC,NewD>
QuadLeftHandSide<NewA,NewB,NewC,NewD>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC, Function<A,NewD> keyMappingD)
<NewA,NewB,NewC,NewD>
QuadLeftHandSide<NewA,NewB,NewC,NewD>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC, UniConstraintCollector<A,?,NewD> collectorD)
<NewA,NewB,NewC>
TriLeftHandSide<NewA,NewB,NewC>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, UniConstraintCollector<A,?,NewC> collectorC)
<NewA,NewB,NewC,NewD>
QuadLeftHandSide<NewA,NewB,NewC,NewD>andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
<NewA,NewB>
BiLeftHandSide<NewA,NewB>andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB)
<NewA,NewB,NewC>
TriLeftHandSide<NewA,NewB,NewC>andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC)
<NewA,NewB,NewC,NewD>
QuadLeftHandSide<NewA,NewB,NewC,NewD>andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
<NewA> UniLeftHandSide<NewA>
andGroupBy(UniConstraintCollector<A,?,NewA> collector)
<NewA,NewB>
BiLeftHandSide<NewA,NewB>andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB)
<NewA,NewB,NewC>
TriLeftHandSide<NewA,NewB,NewC>andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC)
<NewA,NewB,NewC,NewD>
QuadLeftHandSide<NewA,NewB,NewC,NewD>andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
<B> BiLeftHandSide<A,B>
andJoin(UniLeftHandSide<B> right, BiJoiner<A,B> joiner)
<NewA> UniLeftHandSide<NewA>
andMap(Function<A,NewA> mapping)
<B> UniLeftHandSide<A>
andNotExists(Class<B> bClass, BiJoiner<A,B>[] joiners, Predicate<B> nullityFilter)
<Solution_>
RuleBuilder<Solution_>andTerminate()
<Solution_>
RuleBuilder<Solution_>andTerminate(Function<A,BigDecimal> matchWeighter)
<Solution_>
RuleBuilder<Solution_>andTerminate(ToIntFunction<A> matchWeighter)
<Solution_>
RuleBuilder<Solution_>andTerminate(ToLongFunction<A> 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.core.impl.score.stream.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 anIndirectPatternVariable
onBiTuple
with pre-made bindings for its components variables.protected static <A,B,C,D>
org.optaplanner.core.impl.score.stream.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 anIndirectPatternVariable
onQuadTuple
with pre-made bindings for its components variables.protected static <A,B,C>
org.optaplanner.core.impl.score.stream.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 anIndirectPatternVariable
onTriTuple
with pre-made bindings for its components variables.protected static <A,B,C>
org.optaplanner.core.impl.score.stream.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 aDirectPatternVariable
onBiTuple
with pre-made bindings for its components variables and one accumulate output variable.protected static <A,B,C,D>
org.optaplanner.core.impl.score.stream.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 aDirectPatternVariable
onTriTuple
with pre-made bindings for its components variables and one accumulate output variable.protected static org.drools.model.Index.ConstraintType
getConstraintType(JoinerType type)
PatternVariable<A,?,?>
getPatternVariableA()
protected static org.drools.model.view.ViewItem<?>
joinViewItemsWithLogicalAnd(PatternVariable<?,?,?>... patternVariables)
protected static List<org.drools.model.view.ViewItem<?>>
mergeViewItems(PatternVariable<?,?,?>... patternVariables)
-
-
-
Field Detail
-
variableFactory
protected final DroolsVariableFactory variableFactory
-
-
Constructor Detail
-
UniLeftHandSide
public UniLeftHandSide(Class<A> aClass, DroolsVariableFactory variableFactory)
-
UniLeftHandSide
protected UniLeftHandSide(org.drools.model.Variable<A> variable, List<org.drools.model.view.ViewItem<?>> viewItems, DroolsVariableFactory variableFactory)
-
UniLeftHandSide
protected UniLeftHandSide(PatternVariable<A,?,?> patternVariable, DroolsVariableFactory variableFactory)
-
-
Method Detail
-
getPatternVariableA
public PatternVariable<A,?,?> getPatternVariableA()
-
andFilter
public UniLeftHandSide<A> andFilter(Predicate<A> predicate)
-
andExists
public <B> UniLeftHandSide<A> andExists(Class<B> bClass, BiJoiner<A,B>[] joiners, Predicate<B> nullityFilter)
-
andNotExists
public <B> UniLeftHandSide<A> andNotExists(Class<B> bClass, BiJoiner<A,B>[] joiners, Predicate<B> nullityFilter)
-
andJoin
public <B> BiLeftHandSide<A,B> andJoin(UniLeftHandSide<B> right, BiJoiner<A,B> joiner)
-
andGroupBy
public <NewA> UniLeftHandSide<NewA> andGroupBy(UniConstraintCollector<A,?,NewA> collector)
-
andGroupBy
public <NewA,NewB> BiLeftHandSide<NewA,NewB> andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB)
-
andGroupBy
public <NewA,NewB,NewC> TriLeftHandSide<NewA,NewB,NewC> andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC)
-
andGroupBy
public <NewA,NewB,NewC,NewD> QuadLeftHandSide<NewA,NewB,NewC,NewD> andGroupBy(UniConstraintCollector<A,?,NewA> collectorA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
-
andGroupBy
public <NewA> UniLeftHandSide<NewA> andGroupBy(Function<A,NewA> keyMapping)
-
andGroupBy
public <NewA,NewB> BiLeftHandSide<NewA,NewB> andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB)
-
andGroupBy
public <NewA,NewB,NewC> TriLeftHandSide<NewA,NewB,NewC> andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC)
-
andGroupBy
public <NewA,NewB,NewC,NewD> QuadLeftHandSide<NewA,NewB,NewC,NewD> andGroupBy(Function<A,NewA> keyMappingA, UniConstraintCollector<A,?,NewB> collectorB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
-
andGroupBy
public <NewA,NewB> BiLeftHandSide<NewA,NewB> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB)
-
andGroupBy
public <NewA,NewB,NewC> TriLeftHandSide<NewA,NewB,NewC> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, UniConstraintCollector<A,?,NewC> collectorC)
-
andGroupBy
public <NewA,NewB,NewC,NewD> QuadLeftHandSide<NewA,NewB,NewC,NewD> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, UniConstraintCollector<A,?,NewC> collectorC, UniConstraintCollector<A,?,NewD> collectorD)
-
andGroupBy
public <NewA,NewB,NewC> TriLeftHandSide<NewA,NewB,NewC> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC)
-
andGroupBy
public <NewA,NewB,NewC,NewD> QuadLeftHandSide<NewA,NewB,NewC,NewD> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC, UniConstraintCollector<A,?,NewD> collectorD)
-
andGroupBy
public <NewA,NewB,NewC,NewD> QuadLeftHandSide<NewA,NewB,NewC,NewD> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB, Function<A,NewC> keyMappingC, Function<A,NewD> keyMappingD)
-
andMap
public <NewA> UniLeftHandSide<NewA> andMap(Function<A,NewA> mapping)
-
andFlattenLast
public <NewA> UniLeftHandSide<NewA> andFlattenLast(Function<A,Iterable<NewA>> mapping)
-
andTerminate
public <Solution_> RuleBuilder<Solution_> andTerminate()
-
andTerminate
public <Solution_> RuleBuilder<Solution_> andTerminate(ToIntFunction<A> matchWeighter)
-
andTerminate
public <Solution_> RuleBuilder<Solution_> andTerminate(ToLongFunction<A> matchWeighter)
-
andTerminate
public <Solution_> RuleBuilder<Solution_> andTerminate(Function<A,BigDecimal> matchWeighter)
-
getConstraintType
protected static org.drools.model.Index.ConstraintType getConstraintType(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.core.impl.score.stream.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 anIndirectPatternVariable
onBiTuple
with pre-made bindings for its components variables.- Type Parameters:
A
- generic type of the first bound variableB
- generic type of the second bound variable- Parameters:
primaryVariable
- never nullprerequisitePattern
- never null, pattern required to construct the variableboundVarA
- never null,BiTuple.a
boundVarB
- never null,BiTuple.b
- Returns:
- never null
-
decomposeWithAccumulate
protected static <A,B,C> org.optaplanner.core.impl.score.stream.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 aDirectPatternVariable
onBiTuple
with pre-made bindings for its components variables and one accumulate output variable.- Type Parameters:
A
- generic type of the first bound variableB
- generic type of the second bound variableC
- generic type of the accumulate output variable- Parameters:
primaryVariable
- never nullprerequisitePattern
- never null, pattern required to construct the variableboundVarA
- 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.core.impl.score.stream.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 anIndirectPatternVariable
onTriTuple
with pre-made bindings for its components variables.- Type Parameters:
A
- generic type of the first bound variableB
- generic type of the second bound variableC
- generic type of the third bound variable- Parameters:
primaryVariable
- never nullprerequisitePattern
- never null, pattern required to construct the variableboundVarA
- 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.core.impl.score.stream.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 anIndirectPatternVariable
onQuadTuple
with pre-made bindings for its components variables.- Type Parameters:
A
- generic type of the first bound variableB
- generic type of the second bound variableC
- generic type of the third bound variableD
- generic type of the fourth bound variable- Parameters:
primaryVariable
- never nullprerequisitePattern
- never null, pattern required to construct the variableboundVarA
- 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.core.impl.score.stream.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 aDirectPatternVariable
onTriTuple
with pre-made bindings for its components variables and one accumulate output variable.- Type Parameters:
A
- generic type of the first bound variableB
- generic type of the second bound variableC
- generic type of the third bound variableD
- generic type of the accumulate output variable- Parameters:
primaryVariable
- never nullprerequisitePattern
- never null, pattern required to construct the variableboundVarA
- 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)
-
-