This is still not well documented, but one single inheritance exists in drools. It allows you to create a rule that extends another rule. A sub rule will be triggered if and only if both conditions for the super rule and subfield are true. (See My notes below).
In the example below, Flags is a simple Java class with 2 Booleans: isSuperTrue and isSubTrue. The magic phrase extends "super" as part of the definition of the sub rule. The names of the rules (sub and super) are illustrative and can be changed to any name of a legal rule.
rule "super" @description("Fires when isSuperTrue is true regardless of the state of isSubTrue") when $flag : Flags(isSuperTrue == true) then System.out.println("super rule should fire anytime super is true and ignore sub"); end rule "sub" extends "super" @description("Fires only when both isSubTrue and isSuperTrue are true") when Flags(isSubTrue == true) then System.out.println("sub rule should fire when both isSubTrue and isSuperTrue are true"); end
Note 1: In the file 5.5.0. <value> nofollow "> issue is
Note 2: this functionality is indirectly documented in for 5.5.0.Final in section 4.1.1.3. The main topic is Conditional Named Consequences, but it uses rule inheritance.
source share