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 <X> org.drools.model.Variable<? extends X>
createVariable(Class<X> clz, String baseName)
Declare a newVariable
with a given name and no declared source.<X> org.drools.model.Variable<? extends X>
createVariable(Class<X> clz, String baseName, org.drools.model.DeclarationSource source)
Declare a newVariable
with a given name and a declaration source.default <X> org.drools.model.Variable<X>
createVariable(String baseName)
Declares a newObject
-typed variable, seecreateVariable(Class, String, DeclarationSource)
for details.<X> org.drools.model.Variable<? extends X>
createVariable(String baseName, org.drools.model.DeclarationSource source)
Declare a newVariable
with a given name and a declaration source.
-
-
-
Method Detail
-
createVariable
<X> org.drools.model.Variable<? extends X> createVariable(Class<X> clz, String baseName)
Declare a newVariable
with a given name and no declared source. Delegates toDSL.declarationOf(Class, String)
.- Type Parameters:
X
- 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
<X> org.drools.model.Variable<? extends X> createVariable(String baseName, org.drools.model.DeclarationSource source)
Declare a newVariable
with a given name and a declaration source. Delegates toDSL.declarationOf(Class, String, 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
- declaration source of the variable- Returns:
- new variable declaration, not yet bound to anything
-
createVariable
<X> org.drools.model.Variable<? extends X> createVariable(Class<X> clz, String baseName, org.drools.model.DeclarationSource source)
Declare a newVariable
with a given name and a declaration source. Delegates toDSL.declarationOf(Class, String, DeclarationSource)
.- Type Parameters:
X
- 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.source
- declaration 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 newObject
-typed variable, seecreateVariable(Class, String, DeclarationSource)
for details.
-
-