org.optaplanner.core.impl.score.stream.drools.quad

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

- java.lang.Object
- - org.optaplanner.core.impl.score.stream.drools.common.DroolsRuleStructure<PatternVar>
  - - org.optaplanner.core.impl.score.stream.drools.quad.DroolsQuadRuleStructure<A,B,C,D,PatternVar>

-     public class DroolsQuadRuleStructure<A,B,C,D,PatternVar>
      extends DroolsRuleStructure<PatternVar>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `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.
    `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 Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<E> DroolsQuadRuleStructure<A,B,C,D,PatternVar>` | `existsOrNot(org.drools.model.PatternDSL.PatternDef<E> existencePattern, boolean shouldExist)`
    `org.drools.model.Variable<A>` | `getA()`
    `org.drools.model.Variable<B>` | `getB()`
    `org.drools.model.Variable<C>` | `getC()`
    `org.drools.model.Variable<D>` | `getD()`
    `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()`

    - ### 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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

    - #### existsOrNot

          public <E> DroolsQuadRuleStructure<A,B,C,D,PatternVar> existsOrNot(org.drools.model.PatternDSL.PatternDef<E> existencePattern,
                                                                             boolean shouldExist)

    - #### 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.

    - #### getPrerequisites

          public List<org.drools.model.view.ViewItemBuilder<?>> getPrerequisites()

      Description copied from class: `DroolsRuleStructure`
      See `DroolsRuleStructure.getPrimaryPatternBuilder()` for a definition.
      Specified by:
        `getPrerequisites` 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

    - #### getVariableTypes

          protected Class[] getVariableTypes()

      Specified by:
        `getVariableTypes` in class `DroolsRuleStructure<PatternVar>`

Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.