@PersistantProperty(property="source") @PersistantProperty(property="operator") @PersistantProperty(property="reference") @PersistantProperty(property="iterationOperator") @PersistantProperty(property="optimizeMultiEval",defaultValue="true") public class MEvaluationCondition extends AbstractCondition implements IEvaluationCondition
IEvaluationCondition
base implementation, allowing to retrieve 1 or 2 values from IReadAccessor
and to apply test implemented in an operator on these values.
An option allows to optimize multiple evaluation of a same condition by caching result.Modifier and Type | Class and Description |
---|---|
class |
MEvaluationCondition.LiveCastCondition
Allows to dynamically cast values to be able to correctly evaluate the condition.
|
Modifier and Type | Field and Description |
---|---|
static String |
EVAL_ID |
static String |
EVALUATION_FEATURE
The value of this constant ("condition-evaluation") allows to disable caching
of condition evaluations.
|
Constructor and Description |
---|
MEvaluationCondition() |
MEvaluationCondition(boolean not,
IEvaluationOperator operator,
IReadAccessor source,
IReadAccessor reference) |
MEvaluationCondition(IEvaluationOperator operator,
IReadAccessor source,
IReadAccessor reference)
not defaults to false.
|
Modifier and Type | Method and Description |
---|---|
MEvaluationCondition |
clone()
Clones the Addon.
|
void |
compile(ICompilationContext ctxt)
Check presence of operator and validates it.
|
CostInfo |
getEstimatedCost(ICompilationContext ctxt)
Estimates the condition complexity, to allow callers to optimize calls.
|
String |
getImplementationId()
Unique addon implementation ID.
|
ILogicalOperator |
getIterationOperator() |
IEvaluationOperator |
getOperator() |
IReadAccessor |
getReference() |
Class<?> |
getReferenceGenericType(IContext ctxt)
The reference generic type if known and applicable.
|
Class<?> |
getReferenceType(IContext ctxt)
The reference type.
|
Object |
getReferenceValue(IExecutionContext ctxt)
The reference value to evaluate against source value.
|
IReadAccessor |
getSource() |
Class<?> |
getSourceGenericType(IContext ctxt)
The source generic type if known and applicable.
|
Class<?> |
getSourceType(IContext ctxt)
The source type.
|
Object |
getSourceValue(IExecutionContext ctxt)
The source value.
|
protected ConditionEquivalence |
internalIsEquivalent(ICondition o)
Called by
AbstractCondition.internalIsEquivalent(ICondition) if the other condition is not an instance of MConditionNot . |
boolean |
isCacheUsed()
Returns false by default.
|
boolean |
isConstantValue()
Tells if this condition returns a constant result for all executions.
|
boolean |
isOptimizeMultiEval() |
protected boolean |
pEquals(AbstractCondition o)
Tests equality on other parameters than "not".
|
protected boolean |
pEvaluate(IExecutionContext ctxt) |
protected int |
pHashCode()
Computes hashCode on other parameters than "not".
|
protected void |
pToString(OuterWithLevel outer)
Finishes toString output.
|
void |
resetCachedData(IExecutionContext ctxt)
Does nothing.
|
void |
setIterationOperator(ILogicalOperator iterationOperator) |
void |
setNot(boolean not)
Allows to invert condition's behavior.
|
void |
setOperator(IEvaluationOperator operator) |
void |
setOptimizeMultiEval(boolean optimizeMultiEval) |
void |
setReference(IReadAccessor reference) |
void |
setSource(IReadAccessor source) |
boolean |
wasRegistered(ICompilationContext ctxt,
IAddon parent,
AddonInfo info)
Convenience method, which does nothing.
|
combine, combineToNewSet, equals, evaluate, hashCode, isEquivalent, isNot, isShouldBeWrappedToConstantValue, toString
getInternalCacheIdentifier, isInternalCacheIdentifierNeeded, optimize, setInternalCacheIdentifier, toString
getDebugInfo, getDescription, getName, setDebugInfo, setDescription, setName
finalize, getClass, notify, notifyAll, wait, wait, wait
combine, evaluate, isEquivalent, isNot, isShouldBeWrappedToConstantValue
getInternalCacheIdentifier, isInternalCacheIdentifierNeeded, optimize, setInternalCacheIdentifier
getDebugInfo, getDescription, getName, setDebugInfo, setDescription, setName
public static final String EVAL_ID
public static final String EVALUATION_FEATURE
public MEvaluationCondition()
public MEvaluationCondition(IEvaluationOperator operator, IReadAccessor source, IReadAccessor reference)
public MEvaluationCondition(boolean not, IEvaluationOperator operator, IReadAccessor source, IReadAccessor reference)
public void compile(ICompilationContext ctxt) throws MRuleValidationException
compile
in interface ICondition
MRuleValidationException
- if validation problem detected.ICondition.compile(ICompilationContext)
public boolean wasRegistered(ICompilationContext ctxt, IAddon parent, AddonInfo info) throws MRuleValidationException
AbstractAddon
wasRegistered
in interface IAddon
wasRegistered
in class AbstractAddon
parent
- Parent from which this instance of addon was registered.info
- Addon info for the currently registered addonMRuleValidationException
public void resetCachedData(IExecutionContext ctxt)
AbstractAddon
resetCachedData
in interface IAddon
resetCachedData
in class AbstractAddon
public CostInfo getEstimatedCost(ICompilationContext ctxt) throws MRuleValidationException
ICondition
getEstimatedCost
in interface ICondition
MRuleValidationException
- if validation problem detected.public boolean isConstantValue()
ICondition
isConstantValue
in interface ICondition
protected boolean pEvaluate(IExecutionContext ctxt) throws MConditionEvaluationException
pEvaluate
in class AbstractCondition
MConditionEvaluationException
ICondition.evaluate(IExecutionContext)
public Object getSourceValue(IExecutionContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getSourceValue
in interface IEvaluationCondition
MConditionEvaluationException
public Object getReferenceValue(IExecutionContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getReferenceValue
in interface IEvaluationCondition
MConditionEvaluationException
public Class<?> getSourceType(IContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getSourceType
in interface IEvaluationCondition
MConditionEvaluationException
public Class<?> getReferenceType(IContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getReferenceType
in interface IEvaluationCondition
MConditionEvaluationException
public Class<?> getSourceGenericType(IContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getSourceGenericType
in interface IEvaluationCondition
MConditionEvaluationException
public Class<?> getReferenceGenericType(IContext ctxt) throws MConditionEvaluationException
IEvaluationCondition
getReferenceGenericType
in interface IEvaluationCondition
MConditionEvaluationException
public String getImplementationId()
IAddon
getImplementationId
in interface IAddon
public boolean isCacheUsed()
AbstractAddon
isCacheUsed
in interface IAddon
isCacheUsed
in class AbstractAddon
protected void pToString(OuterWithLevel outer) throws IOException
AbstractCondition
pToString
in class AbstractCondition
IOException
protected ConditionEquivalence internalIsEquivalent(ICondition o)
AbstractCondition
AbstractCondition.internalIsEquivalent(ICondition)
if the other condition is not an instance of MConditionNot
.internalIsEquivalent
in class AbstractCondition
public MEvaluationCondition clone()
IAddon
clone
in interface IAddon
clone
in interface IMRulesObject
clone
in interface ICondition
clone
in interface IEvaluationCondition
clone
in class AbstractCondition
protected boolean pEquals(AbstractCondition o)
AbstractCondition
pEquals
in class AbstractCondition
protected int pHashCode()
AbstractCondition
pHashCode
in class AbstractCondition
public void setNot(boolean not)
AbstractCondition
setNot
in interface ICondition
setNot
in class AbstractCondition
public IEvaluationOperator getOperator()
public void setOperator(IEvaluationOperator operator)
public ILogicalOperator getIterationOperator()
public void setIterationOperator(ILogicalOperator iterationOperator)
public IReadAccessor getSource()
public void setSource(IReadAccessor source)
public IReadAccessor getReference()
public void setReference(IReadAccessor reference)
public boolean isOptimizeMultiEval()
public void setOptimizeMultiEval(boolean optimizeMultiEval)