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:
Left-hand side is that part of the rule between the "when" and "then" keywords. The part between the "then" and "end" keywords is called the consequence of the rule, and this class does not represent it. It can be created by callingrule "Simplest univariate rule" when $a: Something() then // Do something with the $a variable. endandTerminate(). There are also more complex variants of rules that still result in just one variable:
To create the simplest possible variant, callrule "Complex univariate rule" when $accumulateResult: Collection() from accumulate( ... ) $a: Object() from $accumulateResult exists Something() then // Do something with the $a variable. endUniLeftHandSide(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 DroolsVariableFactoryvariableFactory
-
Constructor Summary
Constructors Modifier Constructor Description UniLeftHandSide(Class<A> aClass, DroolsVariableFactory variableFactory)protectedUniLeftHandSide(org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A> patternVariable, DroolsVariableFactory variableFactory)protectedUniLeftHandSide(UniLeftHandSide<A> leftHandSide, org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A> patternVariable)
-
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)UniLeftHandSide<A>andFilter(Predicate<A> predicate)<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, 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)<B> UniLeftHandSide<A>andNotExists(Class<B> bClass, BiJoiner<A,B>[] joiners)org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A>andTerminate()org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A>andTerminate(Function<A,BigDecimal> matchWeighter)org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A>andTerminate(ToIntFunction<A> matchWeighter)org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A>andTerminate(ToLongFunction<A> matchWeighter)List<org.drools.model.view.ViewItem<?>>get()protected static org.drools.model.Index.ConstraintTypegetConstraintType(JoinerType type)protected org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A>getPatternVariableA()org.drools.model.Variable[]getVariables()protected static org.drools.model.view.ViewItem<?>joinViewItemsWithLogicalAnd(org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<?>... patternVariables)
-
-
-
Field Detail
-
variableFactory
protected final DroolsVariableFactory variableFactory
-
-
Constructor Detail
-
UniLeftHandSide
public UniLeftHandSide(Class<A> aClass, DroolsVariableFactory variableFactory)
-
UniLeftHandSide
protected UniLeftHandSide(UniLeftHandSide<A> leftHandSide, org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A> patternVariable)
-
UniLeftHandSide
protected UniLeftHandSide(org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A> patternVariable, DroolsVariableFactory variableFactory)
-
-
Method Detail
-
getPatternVariableA
protected org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<A> getPatternVariableA()
-
andFilter
public UniLeftHandSide<A> andFilter(Predicate<A> predicate)
-
andExists
public <B> UniLeftHandSide<A> andExists(Class<B> bClass, BiJoiner<A,B>[] joiners)
-
andNotExists
public <B> UniLeftHandSide<A> andNotExists(Class<B> bClass, BiJoiner<A,B>[] joiners)
-
andJoin
public <B> BiLeftHandSide<A,B> andJoin(UniLeftHandSide<B> right, BiJoiner<A,B> joiner)
-
andGroupBy
public <NewA> UniLeftHandSide<NewA> andGroupBy(Function<A,NewA> keyMapping)
-
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,NewB> BiLeftHandSide<NewA,NewB> andGroupBy(Function<A,NewA> keyMappingA, Function<A,NewB> keyMappingB)
-
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,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)
-
andTerminate
public org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A> andTerminate()
-
andTerminate
public org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A> andTerminate(ToIntFunction<A> matchWeighter)
-
andTerminate
public org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A> andTerminate(ToLongFunction<A> matchWeighter)
-
andTerminate
public org.optaplanner.core.impl.score.stream.drools.common.AbstractUniConstraintConsequence<A> andTerminate(Function<A,BigDecimal> matchWeighter)
-
get
public List<org.drools.model.view.ViewItem<?>> get()
-
getVariables
public org.drools.model.Variable[] getVariables()
-
getConstraintType
protected static org.drools.model.Index.ConstraintType getConstraintType(JoinerType type)
-
joinViewItemsWithLogicalAnd
protected static org.drools.model.view.ViewItem<?> joinViewItemsWithLogicalAnd(org.optaplanner.core.impl.score.stream.drools.common.PatternVariable<?>... patternVariables)
-
-