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

## Class DroolsLogicalTuple

- java.lang.Object
- - org.optaplanner.core.impl.score.stream.drools.common.DroolsLogicalTuple

-     public final class DroolsLogicalTuple
      extends Object

  Used inside Drools-based constraint stream implementation to implement grouping operations. This is the carrier data type which the grouping rule logically inserts into the Drools working memory, so that the following rules can work with the results of the grouping. Instances of this class are equal if they have the same `getRuleId()` and their `getItem(int)` all `Objects.equals(Object, Object)` as well. Drools will not re-insert a fact if equalling fact has already been inserted before.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DroolsLogicalTuple(Object ruleId, Object... items)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `int` | `getCardinality()`
    `<T> T` | `getItem(int index)` Return a fact on n-th position in the tuple.
    `Object` | `getRuleId()`
    `int` | `hashCode()`
    `String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DroolsLogicalTuple

          public DroolsLogicalTuple(Object ruleId,
                                    Object... items)

  - ### Method Detail

    - #### getCardinality

          public int getCardinality()

      Returns:
        number of facts in this tuple. Always greater than zero.

    - #### getRuleId

          public Object getRuleId()

      Returns:
        never null. Unique identifier of the rule that caused the tuple to be logically inserted.

    - #### getItem

          public <T> T getItem(int index)

      Return a fact on n-th position in the tuple.
      Type Parameters:
        `T` - type that we're expecting to see. Method may throw an exception if the cast can not be made.
      Parameters:
        `index` - required position in the tuple. Must be between 0 (incl.) and `getCardinality()` (excl.)
      Returns:
        never null.
      Throws:
        `ArrayIndexOutOfBoundsException` - when index not between 0 (incl.) and `getCardinality()` (excl.)

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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