The java MyRule Class(in the following) introduce executed and result variable. And After firing rules, you query the executed flag on your rule instance and get the execution result.
But how the executed and result variable could be realized in the yml file ? Yml file could introduce global variable? Or only use fact.put('results', xx) in the yml file ?
@Rule(name = "my rule")
public class MyRule<T> {
private boolean executed;
private T result;
//@Condition
public boolean when() {
return true;
}
//@Action
public void then() throws MyException {
try {
System.out.println("my rule has been executed");
result = null; // assign your result here
executed = true;
} catch (MyException e) {
// executed flag will remain false if an exception occurs
throw e;
}
}
public boolean isExecuted() {
return executed;
}
public T getResult() {
return result;
}
}
reference FAQ#2: I would like to return a value upon a rule execution, how to do that?.
The java MyRule Class(in the following) introduce executed and result variable. And After firing rules, you query the executed flag on your rule instance and get the execution result.
But how the executed and result variable could be realized in the yml file ? Yml file could introduce global variable? Or only use fact.put('results', xx) in the yml file ?