Add warning that condition/actions of composite rules will be ignored

pull/241/head
Mahmoud Ben Hassine 5 years ago
parent 2e85745a07
commit 8c78a14964
No known key found for this signature in database
GPG Key ID: 79FCFB0A184E0036

@ -24,6 +24,8 @@
package org.jeasy.rules.support;
import org.jeasy.rules.api.Rule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
@ -37,6 +39,8 @@ import java.util.List;
*/
public abstract class AbstractRuleFactory<C> {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRuleFactory.class);
private static final List<String> ALLOWED_COMPOSITE_RULE_TYPES = Arrays.asList(
UnitRuleGroup.class.getSimpleName(),
ConditionalRuleGroup.class.getSimpleName(),
@ -54,6 +58,20 @@ public abstract class AbstractRuleFactory<C> {
protected abstract Rule createSimpleRule(RuleDefinition ruleDefinition, C parserContext);
protected Rule createCompositeRule(RuleDefinition ruleDefinition, C parserContext) {
if (ruleDefinition.getCondition() != null) {
LOGGER.warn(
"Condition '{}' in composite rule '{}' of type {} will be ignored.",
ruleDefinition.getCondition(),
ruleDefinition.getName(),
ruleDefinition.getCompositeRuleType());
}
if (ruleDefinition.getActions() != null && !ruleDefinition.getActions().isEmpty()) {
LOGGER.warn(
"Actions '{}' in composite rule '{}' of type {} will be ignored.",
ruleDefinition.getActions(),
ruleDefinition.getName(),
ruleDefinition.getCompositeRuleType());
}
CompositeRule compositeRule;
String name = ruleDefinition.getName();
switch (ruleDefinition.getCompositeRuleType()) {

Loading…
Cancel
Save