Class DroolsUniRuleStructure<A,PatternVar>
- java.lang.Object
-
- org.optaplanner.core.impl.score.stream.drools.common.DroolsRuleStructure<PatternVar>
-
- org.optaplanner.core.impl.score.stream.drools.uni.DroolsUniRuleStructure<A,PatternVar>
-
public final class DroolsUniRuleStructure<A,PatternVar> extends DroolsRuleStructure<PatternVar>
-
-
Constructor Summary
Constructors Constructor Description DroolsUniRuleStructure(Class<A> aClass, LongSupplier varialeIdSupplier)
DroolsUniRuleStructure(org.drools.model.Variable<A> aVariable, DroolsPatternBuilder<PatternVar> aPattern, List<org.drools.model.view.ViewItemBuilder<?>> shelved, List<org.drools.model.view.ViewItemBuilder<?>> prerequisites, List<org.drools.model.view.ViewItemBuilder<?>> dependents, LongSupplier variableIdSupplier)
DroolsUniRuleStructure(DroolsBiRuleStructure<A,?,PatternVar> biRuleStructure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DroolsUniRuleStructure<A,PatternVar>
amend(UnaryOperator<org.drools.model.PatternDSL.PatternDef<PatternVar>> expander)
<B> DroolsUniRuleStructure<A,PatternVar>
existsOrNot(org.drools.model.PatternDSL.PatternDef<B> existencePattern, boolean shouldExist)
org.drools.model.Variable<A>
getA()
List<org.drools.model.view.ViewItemBuilder<?>>
getDependents()
Patterns that follow up on the primary pattern, yet are not used for filtering or joining.List<org.drools.model.view.ViewItemBuilder<?>>
getPrerequisites()
SeeDroolsRuleStructure.getPrimaryPatternBuilder()
for a definition.DroolsPatternBuilder<PatternVar>
getPrimaryPatternBuilder()
Primary pattern is the Drools pattern to which operations such as filter and join will be applied.List<org.drools.model.view.ViewItemBuilder<?>>
getShelvedRuleItems()
Patterns that are no longer of any use to the primary pattern, yet are required for the Drools rule to function.protected Class[]
getVariableTypes()
-
Methods inherited from class org.optaplanner.core.impl.score.stream.drools.common.DroolsRuleStructure
createVariable, createVariable, createVariable, createVariable, finish, getExpectedJustificationTypes, getVariableIdSupplier, mergeDependents, mergeShelved, recollect, regroup, regroupBi, regroupBiToQuad, regroupBiToTri
-
-
-
-
Constructor Detail
-
DroolsUniRuleStructure
public DroolsUniRuleStructure(org.drools.model.Variable<A> aVariable, DroolsPatternBuilder<PatternVar> aPattern, List<org.drools.model.view.ViewItemBuilder<?>> shelved, List<org.drools.model.view.ViewItemBuilder<?>> prerequisites, List<org.drools.model.view.ViewItemBuilder<?>> dependents, LongSupplier variableIdSupplier)
-
DroolsUniRuleStructure
public DroolsUniRuleStructure(DroolsBiRuleStructure<A,?,PatternVar> biRuleStructure)
-
DroolsUniRuleStructure
public DroolsUniRuleStructure(Class<A> aClass, LongSupplier varialeIdSupplier)
-
-
Method Detail
-
existsOrNot
public <B> DroolsUniRuleStructure<A,PatternVar> existsOrNot(org.drools.model.PatternDSL.PatternDef<B> existencePattern, boolean shouldExist)
-
amend
public DroolsUniRuleStructure<A,PatternVar> amend(UnaryOperator<org.drools.model.PatternDSL.PatternDef<PatternVar>> expander)
-
getA
public org.drools.model.Variable<A> getA()
-
getShelvedRuleItems
public List<org.drools.model.view.ViewItemBuilder<?>> getShelvedRuleItems()
Description copied from class:DroolsRuleStructure
Patterns that are no longer of any use to the primary pattern, yet are required for the Drools rule to function. Consider the following example left hand side DRL:$tuples: Set() from accumulate(...) // This is the shelved pattern. $person: Person() from $tuples // This is the prerequisite pattern, referencing the shelved pattern. $lesson: Lesson($person in people) // This is the primary pattern, referencing the prerequisite pattern.
In this example, any further Person filters or joiners will still be applied on the primary pattern. Yet the rule overall would not function properly without also including the shelved pattern.The difference between these and
DroolsRuleStructure.getPrerequisites()
is that the latter would be folded inside a subsequent accumulate pattern, while shelved patterns (typically representing previous accumulate patterns) wouldn't. Consider the following example left hand side DRL:$tuples: Set() from accumulate(...) // This is the original shelved pattern from above. $otherTuples: Set() from accumulate( and( $person: Person() from $tuples, // This is the original prerequisite pattern from above. $lesson: Lesson($person in people) // This is the original primary pattern from above. ), collectCount() ) $otherPerson: Person() from $otherTuples // This is the new primary pattern.
- Specified by:
getShelvedRuleItems
in classDroolsRuleStructure<PatternVar>
- Returns:
- never null, a list of preceding items that are required by the primary pattern.
-
getPrerequisites
public List<org.drools.model.view.ViewItemBuilder<?>> getPrerequisites()
Description copied from class:DroolsRuleStructure
SeeDroolsRuleStructure.getPrimaryPatternBuilder()
for a definition.- Specified by:
getPrerequisites
in classDroolsRuleStructure<PatternVar>
- Returns:
- never null, a list of preceding items that are required by the primary pattern
-
getPrimaryPatternBuilder
public DroolsPatternBuilder<PatternVar> getPrimaryPatternBuilder()
Description copied from class:DroolsRuleStructure
Primary pattern is the Drools pattern to which operations such as filter and join will be applied. Consider the following example left hand side DRL:$person: Person() $lesson: Lesson($person in people)
Here, Lesson is the primary pattern of this rule. We can use filters to restrict matched Lesson instances, and we can use $person variable in those filters. But the Person() instances themselves are now fixed and the Person pattern can be found inDroolsRuleStructure.getPrerequisites()
and no longer modified.The primary pattern is provided as a builder. This is necessary since the patterns are shared and modified between different classes and it would therefore be possible for one class to modify the other's pattern. This way, the pattern is only constructed when necessary, at which point it will no longer be shared.
- Specified by:
getPrimaryPatternBuilder
in classDroolsRuleStructure<PatternVar>
- Returns:
- never null, builder that will be used to obtain the final version of the primary pattern
-
getDependents
public List<org.drools.model.view.ViewItemBuilder<?>> getDependents()
Description copied from class:DroolsRuleStructure
Patterns that follow up on the primary pattern, yet are not used for filtering or joining. Consider the following example left hand side DRL:$person: Person() // This is the primary pattern. exists Person(this != $person) // This is the dependent, immutable pattern.
In this example, any further Person filters or joiners will still be applied on the primary pattern. Yet the rule overall would not function properly without also including the dependent pattern.- Specified by:
getDependents
in classDroolsRuleStructure<PatternVar>
- Returns:
- never null, a list of subsequent items that are required by the primary pattern
-
getVariableTypes
protected Class[] getVariableTypes()
- Specified by:
getVariableTypes
in classDroolsRuleStructure<PatternVar>
-
-