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 newVariable
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 newVariable
with a given name and no declared source.<U> org.drools.model.Variable<U>
createVariable(String baseName)
Declares a newObject
-typed variable, seecreateVariable(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 newVariable
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 bycreateVariable(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 bycreateVariable(String, Variable, Variable, BiFunction)
.
-
-
-
Method Detail
-
createVariable
public <U,V extends U> org.drools.model.Variable<V> createVariable(Class<U> clz, String baseName)
Declare a newVariable
with a given name and no declared source. Delegates toDSL.declarationOf(Class, String)
.- Type Parameters:
U
- generic type of the input variableV
- generic type of the output variable- Parameters:
clz
- type of the variable. UsingObject
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 newObject
-typed variable, seecreateVariable(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 newVariable
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 variableV
- generic type of the second input variableResult_
- 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 functionsource2
- never null; value of this is passed to the mapping functionmapping
- 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 bycreateVariable(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 bycreateVariable(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 newVariable
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 variableResult_
- 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 functionmapping
- never null- Returns:
-
-