Class DroolsQuadRuleStructure<A,​B,​C,​D,​PatternVar>


  • public class DroolsQuadRuleStructure<A,​B,​C,​D,​PatternVar>
    extends DroolsRuleStructure<PatternVar>
    • Constructor Detail

      • DroolsQuadRuleStructure

        public DroolsQuadRuleStructure​(DroolsTriRuleStructure<A,​B,​C,​AbcPatternVar> abcRuleStructure,
                                       DroolsUniRuleStructure<D,​PatternVar> dRuleStructure,
                                       LongSupplier variableIdSupplier)
        Builds a final version of the ABC pattern as it will no longer be mutated, and turns the D pattern into the new primary pattern.
        Parameters:
        abcRuleStructure -
        dRuleStructure -
        variableIdSupplier -
      • DroolsQuadRuleStructure

        public DroolsQuadRuleStructure​(org.drools.model.Variable<A> aVariable,
                                       org.drools.model.Variable<B> bVariable,
                                       org.drools.model.Variable<C> cVariable,
                                       org.drools.model.Variable<D> dVariable,
                                       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)
    • Method Detail

      • getA

        public org.drools.model.Variable<A> getA()
      • getB

        public org.drools.model.Variable<B> getB()
      • getC

        public org.drools.model.Variable<C> getC()
      • getD

        public org.drools.model.Variable<D> getD()
      • 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 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.

        Specified by:
        getPrimaryPatternBuilder in class DroolsRuleStructure<PatternVar>
        Returns:
        never null, builder that will be used to obtain the final version of the primary pattern
      • 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 class DroolsRuleStructure<PatternVar>
        Returns:
        never null, a list of preceding items that are required by 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 class DroolsRuleStructure<PatternVar>
        Returns:
        never null, a list of subsequent items that are required by the primary pattern