Interface DroolsVariableFactory
-
public interface DroolsVariableFactory
CreatesVariable
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 <U> org.drools.model.Variable<? extends U>
createVariable(Class<U> clz, String baseName)
Declare a newVariable
with a given name and no declared source.default <U> org.drools.model.Variable<U>
createVariable(String baseName)
Declares a newObject
-typed variable, seecreateVariable(Class, String)
for details.default <U> org.drools.model.Variable<U>
createVariable(String baseName, org.drools.model.Variable<U> source)
As defined bycreateVariable(String, Variable, boolean)
with no flattening.<U> org.drools.model.Variable<U>
createVariable(String baseName, org.drools.model.Variable<U> source, boolean flatten)
Declare a newVariable
with a given name, where the value of the variable will be read from the provided source variable.default <U,Result_>
org.drools.model.Variable<Result_>createVariable(String baseName, org.drools.model.Variable<U> source, Function<U,Result_> mapping)
As defined bycreateVariable(String, Variable, Function, boolean)
with no flattening.<U,Result_>
org.drools.model.Variable<Result_>createVariable(String baseName, org.drools.model.Variable<U> source, Function<U,Result_> mapping, boolean flatten)
Declare a newVariable
with a given name, where the value of the variable will be computed from the provided source variable.default <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)
As defined bycreateVariable(String, Variable, Variable, BiFunction, boolean)
with no flattening.<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.default <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, Variable, Variable, QuadFunction, boolean)
with no flattening.<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.default <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, Variable, TriFunction, boolean)
with no flattening.<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.
-
-
-
Method Detail
-
createVariable
<U> org.drools.model.Variable<? extends U> 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 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
default <U> org.drools.model.Variable<U> createVariable(String baseName, org.drools.model.Variable<U> source)
As defined bycreateVariable(String, Variable, boolean)
with no flattening.
-
createVariable
default <U,Result_> org.drools.model.Variable<Result_> createVariable(String baseName, org.drools.model.Variable<U> source, Function<U,Result_> mapping)
As defined bycreateVariable(String, Variable, Function, boolean)
with no flattening.
-
createVariable
default <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)
As defined bycreateVariable(String, Variable, Variable, BiFunction, boolean)
with no flattening.
-
createVariable
default <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, Variable, TriFunction, boolean)
with no flattening.
-
createVariable
default <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, Variable, Variable, QuadFunction, boolean)
with no flattening.
-
createVariable
default <U> org.drools.model.Variable<U> createVariable(String baseName)
Declares a newObject
-typed variable, seecreateVariable(Class, String)
for details.
-
createVariable
<U> org.drools.model.Variable<U> createVariable(String baseName, org.drools.model.Variable<U> source, boolean flatten)
Declare a newVariable
with a given name, where the value of the variable will be read from the provided source variable. If the value isIterable
, the final argument to this method controls whether the elements will be treated individually or not.- Type Parameters:
U
- 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
- the variable the value of which will be set to the new variableflatten
- if true, we will flatten the collection and return one element after another- Returns:
- never null
-
createVariable
<U,Result_> org.drools.model.Variable<Result_> createVariable(String baseName, org.drools.model.Variable<U> source, Function<U,Result_> mapping, boolean flatten)
Declare a newVariable
with a given name, where the value of the variable will be computed from the provided source variable. If the computed value isIterable
, the final argument to this method controls whether the elements will be treated individually or not.- Type Parameters:
U
- 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
- the variable the value of which will be set to the new variablemapping
- the function to apply on the source variableflatten
- if true, we will flatten the collection and return one element after another- Returns:
- never null
-
createVariable
<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.
-
createVariable
<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.
-
createVariable
<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, boolean flatten)
As defined bycreateVariable(String, Variable, Function, boolean)
.
-
-