Package org.drools.core.base
Class EvaluatorWrapper
- java.lang.Object
-
- org.drools.core.base.EvaluatorWrapper
-
- All Implemented Interfaces:
Serializable,Evaluator,org.kie.api.runtime.rule.Evaluator
public class EvaluatorWrapper extends Object implements Evaluator
An EvaluatorWrapper is used when executing MVEL expressions that have operator calls rewritten as: operator.evaluate( leftArg, rightArg )- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EvaluatorWrapper(Evaluator evaluator, Declaration leftBinding, Declaration rightBinding)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanevaluate(InternalWorkingMemory workingMemory, Object left, Object right)This method is called when operators are rewritten as function calls.booleanevaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value)Evaluates the expression using the provided parameters.booleanevaluate(InternalWorkingMemory workingMemory, InternalReadAccessor leftExtractor, InternalFactHandle left, InternalReadAccessor rightExtractor, InternalFactHandle right)Evaluates the expression using the provided parameters.booleanevaluateCachedLeft(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle right)Evaluates the expression using the provided parameters.booleanevaluateCachedRight(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle left)Evaluates the expression using the provided parameters.StringgetBindingName()ValueTypegetCoercedValueType()Returns the value type this evaluator will coerce operands to, during evaluation.static SelfReferenceClassFieldReadergetExtractor()IntervalgetInterval()In case this is a temporal evaluator, returns the interval in which this evaluator may match the target factorg.kie.api.runtime.rule.OperatorgetOperator()Returns the operator representation object for this evaluatorValueTypegetValueType()Returns the type of the values this evaluator operates upon.booleanisTemporal()Returns true if this evaluator implements a temporal evaluation, i.e., a time sensitive evaluation whose properties of matching only events within an specific time interval can be used for determining event expirations automatically.voidloadHandles(InternalFactHandle[] handles, InternalFactHandle rightHandle)voidsetBindingName(String bindingName)StringtoString()
-
-
-
Constructor Detail
-
EvaluatorWrapper
public EvaluatorWrapper(Evaluator evaluator, Declaration leftBinding, Declaration rightBinding)
-
-
Method Detail
-
evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, Object left, Object right)
This method is called when operators are rewritten as function calls. For instance, x after y Is rewritten as after.evaluate( _workingMemory_, x, y )- Returns:
-
getValueType
public ValueType getValueType()
Description copied from interface:EvaluatorReturns the type of the values this evaluator operates upon.- Specified by:
getValueTypein interfaceEvaluator- Returns:
- See Also:
Evaluator.getValueType()
-
getOperator
public org.kie.api.runtime.rule.Operator getOperator()
Description copied from interface:EvaluatorReturns the operator representation object for this evaluator- Specified by:
getOperatorin interfaceEvaluator- Specified by:
getOperatorin interfaceorg.kie.api.runtime.rule.Evaluator- Returns:
- See Also:
Evaluator.getOperator()
-
getCoercedValueType
public ValueType getCoercedValueType()
Description copied from interface:EvaluatorReturns the value type this evaluator will coerce operands to, during evaluation. This is useful for operators like "memberOf", that always convert to Object when evaluating, independently of the source operand value type.- Specified by:
getCoercedValueTypein interfaceEvaluator- Returns:
- See Also:
Evaluator.getCoercedValueType()
-
evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value)
Description copied from interface:EvaluatorEvaluates the expression using the provided parameters. This method is used when evaluating alpha-constraints, i.e., a fact attribute against a constant value. For instance: Person( name == "Bob" ) So, it uses a constant value "Bob" that is sent into the method as the FieldValue (value), and compares it to the value of the name field, read by using the extractor on the fact instance (object1).- Specified by:
evaluatein interfaceEvaluator- Parameters:
workingMemory-extractor-factHandle-value-- Returns:
- See Also:
Evaluator.evaluate(org.drools.core.common.InternalWorkingMemory, org.drools.core.spi.InternalReadAccessor, InternalFactHandle, org.drools.core.spi.FieldValue)
-
evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor leftExtractor, InternalFactHandle left, InternalReadAccessor rightExtractor, InternalFactHandle right)
Description copied from interface:EvaluatorEvaluates the expression using the provided parameters. This method is used for internal indexing and hashing, when drools needs to extract and evaluate both left and right values at once. For instance: Person( name == $someName ) This method will be used to extract and evaluate both the "name" attribute and the "$someName" variable at once.- Specified by:
evaluatein interfaceEvaluator- Parameters:
workingMemory-leftExtractor-left-rightExtractor-right-- Returns:
- See Also:
Evaluator.evaluate(org.drools.core.common.InternalWorkingMemory, org.drools.core.spi.InternalReadAccessor, InternalFactHandle, org.drools.core.spi.InternalReadAccessor, InternalFactHandle)
-
evaluateCachedLeft
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle right)
Description copied from interface:EvaluatorEvaluates the expression using the provided parameters. This method is used when evaluating left-activated beta-constraints, i.e., a fact attribute against a variable value, that is activated from the left. For instance: Person( name == $someName ) This method will be used when a new $someName variable is bound. So it will cache the value of $someName and will iterate over the right memory (Person instances) evaluating each occurrence.- Specified by:
evaluateCachedLeftin interfaceEvaluator- Parameters:
workingMemory-context-right-- Returns:
- See Also:
Evaluator.evaluateCachedLeft(org.drools.core.common.InternalWorkingMemory, org.drools.core.rule.VariableRestriction.VariableContextEntry, InternalFactHandle)
-
evaluateCachedRight
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle left)
Description copied from interface:EvaluatorEvaluates the expression using the provided parameters. This method is used when evaluating right-activated beta-constraints, i.e., a fact attribute against a variable value, that is activated from the right. For instance: Person( name == $someName ) This method will be used when a new Person instance is evaluated. So it will cache the value of the "Person" instance and will iterate over the left memory comparing it to each "$someName" bound values.- Specified by:
evaluateCachedRightin interfaceEvaluator- Parameters:
workingMemory-context-left-- Returns:
- See Also:
Evaluator.evaluateCachedRight(org.drools.core.common.InternalWorkingMemory, org.drools.core.rule.VariableRestriction.VariableContextEntry, InternalFactHandle)
-
isTemporal
public boolean isTemporal()
Description copied from interface:EvaluatorReturns true if this evaluator implements a temporal evaluation, i.e., a time sensitive evaluation whose properties of matching only events within an specific time interval can be used for determining event expirations automatically.- Specified by:
isTemporalin interfaceEvaluator- Specified by:
isTemporalin interfaceorg.kie.api.runtime.rule.Evaluator- Returns:
- See Also:
Evaluator.isTemporal()
-
getInterval
public Interval getInterval()
Description copied from interface:EvaluatorIn case this is a temporal evaluator, returns the interval in which this evaluator may match the target fact- Specified by:
getIntervalin interfaceEvaluator- Returns:
- See Also:
Evaluator.getInterval()
-
loadHandles
public void loadHandles(InternalFactHandle[] handles, InternalFactHandle rightHandle)
-
getExtractor
public static SelfReferenceClassFieldReader getExtractor()
-
getBindingName
public String getBindingName()
-
setBindingName
public void setBindingName(String bindingName)
-
-