Class ConditionalRuleGroup
- java.lang.Object
-
- org.rossonet.ext.rules.core.BasicRule
-
- org.rossonet.ext.rules.support.composite.CompositeRule
-
- org.rossonet.ext.rules.support.composite.ConditionalRuleGroup
-
public class ConditionalRuleGroup extends CompositeRule
A conditional rule group is a composite rule where the rule with the highest priority acts as a condition: if the rule with the highest priority evaluates to true, then we try to evaluate the rest of the rules and execute the ones that evaluate to true. This class is not thread-safe.
-
-
Field Summary
-
Fields inherited from class org.rossonet.ext.rules.support.composite.CompositeRule
rules
-
Fields inherited from class org.rossonet.ext.rules.core.BasicRule
description, name, priority
-
Fields inherited from interface org.rossonet.ext.rules.api.Rule
DEFAULT_DESCRIPTION, DEFAULT_NAME, DEFAULT_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description ConditionalRuleGroup()Create a conditional rule group.ConditionalRuleGroup(java.lang.String name)Create a conditional rule group.ConditionalRuleGroup(java.lang.String name, java.lang.String description)Create a conditional rule group.ConditionalRuleGroup(java.lang.String name, java.lang.String description, int priority)Create a conditional rule group.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanevaluate(Facts facts)A conditional rule group will trigger all its composing rules if the condition of the rule with highest priority evaluates to true.voidexecute(Facts facts)When a conditional rule group is executed, all rules that evaluated to true are performed in their natural order, but with the conditional rule (the one with the highest priority) first.-
Methods inherited from class org.rossonet.ext.rules.support.composite.CompositeRule
addRule, removeRule
-
Methods inherited from class org.rossonet.ext.rules.core.BasicRule
compareTo, equals, getDescription, getName, getPriority, hashCode, setDescription, setPriority, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.rossonet.ext.rules.api.Rule
isTraceEnable
-
-
-
-
Constructor Detail
-
ConditionalRuleGroup
public ConditionalRuleGroup()
Create a conditional rule group.
-
ConditionalRuleGroup
public ConditionalRuleGroup(java.lang.String name)
Create a conditional rule group.- Parameters:
name- of the conditional rule
-
ConditionalRuleGroup
public ConditionalRuleGroup(java.lang.String name, java.lang.String description)Create a conditional rule group.- Parameters:
name- of the conditional ruledescription- of the conditional rule
-
ConditionalRuleGroup
public ConditionalRuleGroup(java.lang.String name, java.lang.String description, int priority)Create a conditional rule group.- Parameters:
name- of the conditional ruledescription- of the conditional rulepriority- of the composite rule
-
-
Method Detail
-
evaluate
public boolean evaluate(Facts facts)
A conditional rule group will trigger all its composing rules if the condition of the rule with highest priority evaluates to true.- Specified by:
evaluatein interfaceRule- Specified by:
evaluatein classCompositeRule- Parameters:
facts- The facts.- Returns:
- true if the conditions of all composing rules evaluate to true
-
execute
public void execute(Facts facts) throws java.lang.Exception
When a conditional rule group is executed, all rules that evaluated to true are performed in their natural order, but with the conditional rule (the one with the highest priority) first.- Specified by:
executein interfaceRule- Specified by:
executein classCompositeRule- Parameters:
facts- The facts.- Throws:
java.lang.Exception- thrown if an exception occurs during actions performing
-
-