Package org.drools.ruleunits.api

## Interface RuleUnitInstance<T extends RuleUnitData>

- Type Parameters:
    `T` - The `RuleUnitData` for which this rule unit is generated.
  All Superinterfaces:
    `AutoCloseable`

      public interface RuleUnitInstance<T extends RuleUnitData>
      extends AutoCloseable

  An instance of a `RuleUnit` working on the data contained in a specific `RuleUnitData`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Releases all resources used by this RuleUnitInstance, setting it up for garbage collection.
    `QueryResults` | `executeQuery​(String query, Object... arguments)` | Executes the query with the given name on this instance, using the given set of arguments
    `int` | `fire()` | Trigger the pattern matching algorithm on all the facts contained in the `DataSource`s of the `RuleUnitData` used by this RuleUnitInstance and fires all the rules activated by them.
    `<T extends SessionClock> T` | `getClock()` |
    `T` | `ruleUnitData()` | The instance of `RuleUnitData` containing the data used by this RuleUnitInstance.
    `RuleUnit<T>` | `unit()` | The `RuleUnit` from which this RuleUnitInstance has been created.

- - ### Method Detail

    - #### unit

          RuleUnit<T> unit()

      The `RuleUnit` from which this RuleUnitInstance has been created.

    - #### ruleUnitData

          T ruleUnitData()

      The instance of `RuleUnitData` containing the data used by this RuleUnitInstance.

    - #### fire

          int fire()

      Trigger the pattern matching algorithm on all the facts contained in the `DataSource`s of the `RuleUnitData` used by this RuleUnitInstance and fires all the rules activated by them.
      Returns:
        The number of fired rules.

    - #### executeQuery

          QueryResults executeQuery​(String query,
                                    Object... arguments)

      Executes the query with the given name on this instance, using the given set of arguments
      Parameters:
        `query` - The name of the query to be executed
        `arguments` - The arguments to be passed to the query
      Returns:
        TODO this should return a `QueryResults`

    - #### getClock

          <T extends SessionClock> T getClock()

      Returns:
        the session clock instance used by this RuleUnitInstance

    - #### close

          void close()

      Releases all resources used by this RuleUnitInstance, setting it up for garbage collection. This method must always be called after finishing using the RuleUnitInstance, or the engine will not free the memory it uses.
      Specified by:
        `close` in interface `AutoCloseable`