您好,我想知道在 Drools 中如何解释以下规则
rule "test"
when
condiction A
or
condiction B
condiction C
then something
end
是吗
(A 或 B)和 C
A 或(B 和 C)
变成两条规则:a)。 A 和 C b). B和C
变成两条规则:a)。乙)。 B和C
谢谢
最佳答案
Drools 中的运算符优先级(很大程度上)遵循 Java 运算符优先级。 And (&) 在 or (|) 之前评估,后者在 之前评估逻辑与 (&&),在逻辑或 (||) 之前计算。
Operator precedence ----> & | && ||
Note that Drools does support explicit operand grouping with parentheses, so when in doubt use them. As is, in your example the evaluation order corresponds to #2:
A or (B and C)
This ordering is then compiled into two rules, based off the groupings:
A
B and C
随后可能会激活这些规则中的任何一个,具体取决于您的型号。
所有这些都在高度推荐的 Drools documentation 中进行了解释。 .
关于java - Drools 规则中的运算符优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13913469/