]
Mario Fusco closed JBRULES-3620.
--------------------------------
Resolution: Done
Conditional named consequences
------------------------------
Key: JBRULES-3620
URL:
https://issues.jboss.org/browse/JBRULES-3620
Project: JBRULES
Issue Type: Feature Request
Reporter: Mario Fusco
Assignee: Mario Fusco
Implement named consequence like in the following example:
{{rule R1}}
{{A() do\[t1\] B()}}
{{then}}
{{// default consequence executed with both A() and B()}}
{{then\[t1\]}}
{{// named consequence on A()}}
{{end}}
In this example, when a match for A() is found, the consequence named t1 is scheduled on
the agenda and then the LHS pattern matching evaluation continues as per normal looking
for a join with B() and eventually scheduling also the default consequence.
The named consequence activation can be optionally guarded by a condition like in:
{{A() if (condition) do\[t1\] B()}}
Here the named consequence t1 is activated only if the boolean condition (expressed on
the last pattern before the if, A() in this case) evaluates to true. The conditional named
consequence invocation can be also breaking, i.e. can block any further pattern matching
when the condition is satisfied like in:
{{A() if (condition) break\[t1\] B()}}
Note that the use of a breaking named consequence without any condition like in:
{{A() break\[t1\] B()}}
doesn't make sense (and should generate a compile time error) because the join with
B() shouldn't be reachable.
Using one or more if/else it is also possible to have multiple nested conditions like in
the following example:
{{A() if (condition1) do\[t1\] else if (condition2) do\[t2\] else break\[t3\] B()}}