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

## Interface DroolsVariableFactory

-     public interface DroolsVariableFactory

  Creates `Variable`s with unique names, by adding numeric suffixes to the user-provided names. Drools executable model unfortunately doesn't enforce unique variable names, yet requires them - therefore, by unifying all access to variable creation through the factory we avoid avoiding all sorts of strange issues that are very hard to track down.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<X> org.drools.model.Variable<? extends X>` | `createVariable​(Class<X> clz, String baseName)` | Declare a new `Variable` with a given name and no declared source.
    `default <X> org.drools.model.Variable<X>` | `createVariable​(String baseName)` | Declares a new `Object`-typed variable, see `createVariable(Class, String)` for details.
    `<X> org.drools.model.Variable<X>` | `createVariable​(String baseName, org.drools.model.Variable<X> source)` | Declare a new `Variable` with a given name, the contents of which will be identical to the source variable.

- - ### Method Detail

    - #### createVariable

          <X> org.drools.model.Variable<? extends X> createVariable​(Class<X> clz,
                                                                    String baseName)

      Declare a new `Variable` with a given name and no declared source. Delegates to `DSL.declarationOf(Class, String)`.
      Type Parameters:
        `X` - generic type of the variable
      Parameters:
        `clz` - type of the variable. Using `Object` will work in all cases, but Drools will spend unnecessary amount of time looking up applicable instances of that variable, as it has to traverse instances of all types in the working memory. Therefore, it is desirable to be as specific as possible.
        `baseName` - name of the variable, mostly useful for debugging purposes. Will be decorated by a numeric identifier to prevent multiple variables of the same name to exist within left-hand side of a single rule.
      Returns:
        new variable declaration, not yet bound to anything

    - #### createVariable

          <X> org.drools.model.Variable<X> createVariable​(String baseName,
                                                          org.drools.model.Variable<X> source)

      Declare a new `Variable` with a given name, the contents of which will be identical to the source variable. Delegates to `DSL.declarationOf(Class, String, org.drools.model.DeclarationSource)`.
      Type Parameters:
        `X` - generic type of the variable
      Parameters:
        `baseName` - name of the variable, mostly useful for debugging purposes. Will be decorated by a numeric identifier to prevent multiple variables of the same name to exist within left-hand side of a single rule.
        `source` - source of the variable
      Returns:
        new variable declaration, not yet bound to anything

    - #### createVariable

          default <X> org.drools.model.Variable<X> createVariable​(String baseName)

      Declares a new `Object`-typed variable, see `createVariable(Class, String)` for details.