Rule weatherRule = new RuleBuilder()
.name("weather rule")
.description("if it rains then take an umbrella")
.when(facts -> facts.get("rain").equals(true))
.then(facts -> System.out.println("It rains, take an umbrella!"))
.build();
Or using an Expression Language:
Rule weatherRule = new MVELRule()
.name("weather rule")
.description("if it rains then take an umbrella")
.when("rain == true")
.then("System.out.println(\"It rains, take an umbrella!\");");
How to get:
...
.when("rain == true")
.then(facts -> System.out.println("It rains, take an umbrella!"))
...
Currently, I have to take it in:
MVELRule weatherMvelRule = new MVELRule()
.name("weather rule")
.description("if it rains then take an umbrella")
.when("rain == true");
Facts facts = new Facts();
facts.put("rain", true);
if (weatherMvelRule.evaluate(facts)) {
System.out.println("It rains, take an umbrella!");
}
In a programmatic way with a fluent API:
Or using an Expression Language:
How to get:
Currently, I have to take it in: