easy-rules currently supports three combination mode rules. The following is an introduction. In fact, we can refer to the implementation for expansion
UnitRuleGroup
- Code
@Override
public boolean evaluate(Facts facts) {
if (!rules.isEmpty()) {
for (Rule rule : rules) {
if (!rule.evaluate(facts)) {
return false;
}
}
return true;
}
return false;
}
- Description
As long as a non-compliance, they do not perform, that is, either perform or not to perform
ActivationRuleGroup
- Code
@Override
public boolean evaluate(Facts facts) {
for (Rule rule : rules) {
if (rule.evaluate(facts)) {
selectedRule = rule;
return true;
}
}
return false;
}
- Description
Select the first, the other is not performed
ConditionalRuleGroup
- Code
@Override
public boolean evaluate(Facts facts) {
successfulEvaluations = new HashSet<>();
conditionalRule = getRuleWithHighestPriority();
if (conditionalRule.evaluate(facts)) {
for (Rule rule : rules) {
if (rule != conditionalRule && rule.evaluate(facts)) {
successfulEvaluations.add(rule);
}
}
return true;
}
return false;
}
- Description
find the highest priority, if so, then find other rule matching and execution
Explanation
If you look at the official introduction, look at the name and function, it is not a good match, it will be better to combine the source code