All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.lostred.ruler.engine.CompleteRulesEngine Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package info.lostred.ruler.engine;

import info.lostred.ruler.domain.Result;
import info.lostred.ruler.factory.RuleFactory;
import info.lostred.ruler.rule.AbstractRule;
import org.springframework.expression.BeanResolver;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.lang.reflect.Method;
import java.util.List;

/**
 * 完全执行返回详细结果的规则引擎
 *
 * @author lostred
 */
public class CompleteRulesEngine extends DetailRulesEngine {
    public CompleteRulesEngine(RuleFactory ruleFactory, String businessType,
                               BeanResolver beanResolver, ExpressionParser parser, List globalFunctions) {
        super(ruleFactory, businessType, beanResolver, parser, globalFunctions);
    }

    @Override
    public Result execute(Object object) {
        StandardEvaluationContext context = new StandardEvaluationContext(object);
        this.setBeanResolver(context);
        this.registerFunctions(context, globalFunctions);
        Result result = Result.of();
        for (AbstractRule rule : rules) {
            this.handle(context, object, result, rule);
        }
        result.statistic();
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy