Rule inheritance
One last important aspect of rule creation is the possibility of having a rule hierarchy. Just like classes, rules allow inheritance between them. If rule B
inherits rule A
, it will be the same as having all the conditions in rule A
at the beginning of the conditions of rule B
. The following table shows two rules using inheritance and their equivalent without it:
rule "A" whens: String(this == "A") thenSystem.out.println(s); end rule "B" extends "A" when i: Integer(intValue > 2) then System.out.println(i); end
|
rule "A" whens: String(this == "A") thenSystem.out.println(s); end rule "B" whens: String(this == "A")i: Integer(intValue > 2) thenSystem.out.println(i); end
|
This can be a good strategy to manage rules that have repetitive ...
Get Mastering JBoss Drools 6 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.