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

## Class DroolsVariableFactory

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

-     public final class DroolsVariableFactory
      extends Object

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<U,​Result_> org.drools.model.Variable<Result_>` | `createFlattenedVariable​(String baseName, org.drools.model.Variable<U> source, Function<U,​Iterable<Result_>> mapping)` | Declare a new `Variable` with a given name, which will hold the individual results of applying the given mapping function on the value of the provided variable.
    `<U,​V extends U> org.drools.model.Variable<V>` | `createVariable​(Class<U> clz, String baseName)` | Declare a new `Variable` with a given name and no declared source.
    `<U> org.drools.model.Variable<U>` | `createVariable​(String baseName)` | Declares a new `Object`-typed variable, see `createVariable(Class, String)` for details.
    `<U,​V,​Result_> org.drools.model.Variable<Result_>` | `createVariable​(String baseName, org.drools.model.Variable<U> source1, org.drools.model.Variable<V> source2, BiFunction<U,​V,​Result_> mapping)` | Declare a new `Variable` with a given name, which will hold the result of applying a given mapping function on values of the provided variables.
    `<U,​V,​W,​Y,​Result_> org.drools.model.Variable<Result_>` | `createVariable​(String baseName, org.drools.model.Variable<U> source1, org.drools.model.Variable<V> source2, org.drools.model.Variable<W> source3, org.drools.model.Variable<Y> source4, QuadFunction<U,​V,​W,​Y,​Result_> mapping)` | As defined by `createVariable(String, Variable, Variable, BiFunction)`.
    `<U,​V,​W,​Result_> org.drools.model.Variable<Result_>` | `createVariable​(String baseName, org.drools.model.Variable<U> source1, org.drools.model.Variable<V> source2, org.drools.model.Variable<W> source3, TriFunction<U,​V,​W,​Result_> mapping)` | As defined by `createVariable(String, Variable, Variable, BiFunction)`.

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

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

- - ### Method Detail

    - #### createVariable

          public <U,​V extends U> org.drools.model.Variable<V> createVariable​(Class<U> clz,
                                                                                   String baseName)

      Declare a new `Variable` with a given name and no declared source. Delegates to `DSL.declarationOf(Class, String)`.
      Type Parameters:
        `U` - generic type of the input variable
        `V` - generic type of the output 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

          public <U> org.drools.model.Variable<U> createVariable​(String baseName)

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

    - #### createVariable

          public <U,​V,​Result_> org.drools.model.Variable<Result_> createVariable​(String baseName,
                                                                                             org.drools.model.Variable<U> source1,
                                                                                             org.drools.model.Variable<V> source2,
                                                                                             BiFunction<U,​V,​Result_> mapping)

      Declare a new `Variable` with a given name, which will hold the result of applying a given mapping function on values of the provided variables.
      Type Parameters:
        `U` - generic type of the first input variable
        `V` - generic type of the second input variable
        `Result_` - generic type of the new 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.
        `source1` - never null; value of this is passed to the mapping function
        `source2` - never null; value of this is passed to the mapping function
        `mapping` - never null
      Returns:
        never null

    - #### createVariable

          public <U,​V,​W,​Result_> org.drools.model.Variable<Result_> createVariable​(String baseName,
                                                                                                     org.drools.model.Variable<U> source1,
                                                                                                     org.drools.model.Variable<V> source2,
                                                                                                     org.drools.model.Variable<W> source3,
                                                                                                     TriFunction<U,​V,​W,​Result_> mapping)

      As defined by `createVariable(String, Variable, Variable, BiFunction)`.

    - #### createVariable

          public <U,​V,​W,​Y,​Result_> org.drools.model.Variable<Result_> createVariable​(String baseName,
                                                                                                             org.drools.model.Variable<U> source1,
                                                                                                             org.drools.model.Variable<V> source2,
                                                                                                             org.drools.model.Variable<W> source3,
                                                                                                             org.drools.model.Variable<Y> source4,
                                                                                                             QuadFunction<U,​V,​W,​Y,​Result_> mapping)

      As defined by `createVariable(String, Variable, Variable, BiFunction)`.

    - #### createFlattenedVariable

          public <U,​Result_> org.drools.model.Variable<Result_> createFlattenedVariable​(String baseName,
                                                                                              org.drools.model.Variable<U> source,
                                                                                              Function<U,​Iterable<Result_>> mapping)

      Declare a new `Variable` with a given name, which will hold the individual results of applying the given mapping function on the value of the provided variable. Each such result will trigger a single rule firing. (Default behavior of Drools' From node.)
      Type Parameters:
        `U` - generic type of the input variable
        `Result_` - generic type of the new 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` - never null; value of this is passed to the mapping function
        `mapping` - never null
      Returns: