use of org.jeasy.rules.api.RulesEngine in project easy-rules by j-easy.
the class Launcher method main.
public static void main(String[] args) {
// define facts
Facts facts = new Facts();
facts.put("temperature", 30);
// define rules
Rule airConditioningRule = new RuleBuilder().name("air conditioning rule").when(itIsHot()).then(decreaseTemperature()).build();
Rules rules = new Rules();
rules.register(airConditioningRule);
// fire rules on known facts
RulesEngine rulesEngine = new InferenceRulesEngine();
rulesEngine.fire(rules, facts);
}
use of org.jeasy.rules.api.RulesEngine 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();
}
}
use of org.jeasy.rules.api.RulesEngine 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);
}
use of org.jeasy.rules.api.RulesEngine 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);
}
Aggregations