Search in sources :

Example 16 with Rules

use of org.jeasy.rules.api.Rules in project easy-rules by j-easy.

the class FizzBuzzWithEasyRules method main.

public static void main(String[] args) {
    // create rules engine
    RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstAppliedRule(true);
    RulesEngine fizzBuzzEngine = new DefaultRulesEngine(parameters);
    // create rules
    Rules rules = new Rules();
    rules.register(new FizzRule());
    rules.register(new BuzzRule());
    rules.register(new FizzBuzzRule(new FizzRule(), new BuzzRule()));
    rules.register(new NonFizzBuzzRule());
    // fire rules
    Facts facts = new Facts();
    for (int i = 1; i <= 100; i++) {
        facts.put("number", i);
        fizzBuzzEngine.fire(rules, facts);
        System.out.println();
    }
}
Also used : DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) RulesEngine(org.jeasy.rules.api.RulesEngine) RulesEngineParameters(org.jeasy.rules.core.RulesEngineParameters) Rules(org.jeasy.rules.api.Rules) Facts(org.jeasy.rules.api.Facts)

Example 17 with Rules

use of org.jeasy.rules.api.Rules in project easy-rules by j-easy.

the class Launcher method main.

public static void main(String[] args) {
    // create facts
    Facts facts = new Facts();
    // create rules
    Rules rules = new Rules();
    rules.register(new HelloWorldRule());
    // create a rules engine and fire rules on known facts
    RulesEngine rulesEngine = new DefaultRulesEngine();
    rulesEngine.fire(rules, facts);
}
Also used : DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) RulesEngine(org.jeasy.rules.api.RulesEngine) Rules(org.jeasy.rules.api.Rules) Facts(org.jeasy.rules.api.Facts)

Example 18 with Rules

use of org.jeasy.rules.api.Rules in project tutorials by eugenp.

the class Launcher method main.

public static void main(String... args) {
    // create facts
    Facts facts = new Facts();
    // create rules
    Rules rules = new Rules();
    rules.register(new HelloWorldRule());
    // create a rules engine and fire rules on known facts
    RulesEngine rulesEngine = new DefaultRulesEngine();
    rulesEngine.fire(rules, facts);
}
Also used : DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) RulesEngine(org.jeasy.rules.api.RulesEngine) Rules(org.jeasy.rules.api.Rules) Facts(org.jeasy.rules.api.Facts)

Aggregations

Rules (org.jeasy.rules.api.Rules)18 Facts (org.jeasy.rules.api.Facts)16 RulesEngine (org.jeasy.rules.api.RulesEngine)13 Test (org.junit.Test)10 DefaultRulesEngine (org.jeasy.rules.core.DefaultRulesEngine)6 Rule (org.jeasy.rules.annotation.Rule)2 File (java.io.File)1 Rule (org.jeasy.rules.api.Rule)1 InferenceRulesEngine (org.jeasy.rules.core.InferenceRulesEngine)1 RuleBuilder (org.jeasy.rules.core.RuleBuilder)1 RulesEngineParameters (org.jeasy.rules.core.RulesEngineParameters)1 MVELRule (org.jeasy.rules.mvel.MVELRule)1 Before (org.junit.Before)1