public final class DroolsBiRuleStructure<A,B,PatternVar> extends DroolsRuleStructure<PatternVar>
Constructor and Description |
---|
DroolsBiRuleStructure(DroolsUniRuleStructure<A,APatternVar> aRuleStructure,
DroolsUniRuleStructure<B,PatternVar> bRuleStructure,
LongSupplier variableIdSupplier) |
DroolsBiRuleStructure(org.drools.model.Variable<A> aVariable,
org.drools.model.Variable<B> bVariable,
DroolsPatternBuilder<PatternVar> primaryPattern,
List<org.drools.model.view.ViewItemBuilder<?>> shelved,
List<org.drools.model.view.ViewItemBuilder<?>> prerequisites,
List<org.drools.model.view.ViewItemBuilder<?>> dependents,
LongSupplier variableIdSupplier) |
Modifier and Type | Method and Description |
---|---|
<C> DroolsBiRuleStructure<A,B,PatternVar> |
existsOrNot(org.drools.model.PatternDSL.PatternDef<C> existencePattern,
boolean shouldExist) |
org.drools.model.Variable<A> |
getA() |
org.drools.model.Variable<B> |
getB() |
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()
See
DroolsRuleStructure.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() |
createVariable, createVariable, createVariable, createVariable, finish, getExpectedJustificationTypes, getVariableIdSupplier, mergeDependents, mergeShelved, recollect, regroup, regroupBi, regroupBiToQuad, regroupBiToTri
public DroolsBiRuleStructure(DroolsUniRuleStructure<A,APatternVar> aRuleStructure, DroolsUniRuleStructure<B,PatternVar> bRuleStructure, LongSupplier variableIdSupplier)
public DroolsBiRuleStructure(org.drools.model.Variable<A> aVariable, org.drools.model.Variable<B> bVariable, DroolsPatternBuilder<PatternVar> primaryPattern, List<org.drools.model.view.ViewItemBuilder<?>> shelved, List<org.drools.model.view.ViewItemBuilder<?>> prerequisites, List<org.drools.model.view.ViewItemBuilder<?>> dependents, LongSupplier variableIdSupplier)
public <C> DroolsBiRuleStructure<A,B,PatternVar> existsOrNot(org.drools.model.PatternDSL.PatternDef<C> existencePattern, boolean shouldExist)
public org.drools.model.Variable<A> getA()
public org.drools.model.Variable<B> getB()
public List<org.drools.model.view.ViewItemBuilder<?>> getShelvedRuleItems()
DroolsRuleStructure
$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.
getShelvedRuleItems
in class DroolsRuleStructure<PatternVar>
public List<org.drools.model.view.ViewItemBuilder<?>> getPrerequisites()
DroolsRuleStructure
DroolsRuleStructure.getPrimaryPatternBuilder()
for a definition.getPrerequisites
in class DroolsRuleStructure<PatternVar>
public DroolsPatternBuilder<PatternVar> getPrimaryPatternBuilder()
DroolsRuleStructure
$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 in
DroolsRuleStructure.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.
getPrimaryPatternBuilder
in class DroolsRuleStructure<PatternVar>
public List<org.drools.model.view.ViewItemBuilder<?>> getDependents()
DroolsRuleStructure
$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.
getDependents
in class DroolsRuleStructure<PatternVar>
protected Class[] getVariableTypes()
getVariableTypes
in class DroolsRuleStructure<PatternVar>
Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.