Drools规则中的运算符优先级

时间:2012-12-17 11:40:24

标签: java drools jbpm mvel

您好我想知道如何在Drools中解释以下规则

rule "test"
when
    condiction A
    or
    condiction B
    condiction C
then something
end

是吗

  1. (A或B)和C

  2. A或(B和C)

  3. 成为两条规则:a)。 A和C b)。 B和C

  4. 成为两条规则:a)。 A b)。 B和C

  5. 谢谢

1 个答案:

答案 0 :(得分:2)

Drools中的运算符优先级(主要是)遵循Java运算符优先级。 Ands (&)在 ors (|)之前进行评估,在 logical ands (&&),在 logical ors (||)之前评估。

Operator precedence ---->

&    |    &&    ||

请注意,Drools 支持使用括号进行显式操作数分组,因此如果有疑问,请使用它们。在您的示例中,评估顺序对应于#2:

A或(B和C)

然后根据分组将此排序编译成两个规则:

A
B and C

然后可以激活这些规则中的任何一个,具体取决于您的型号。

所有这些都在 高度 推荐Drools documentation中进行了解释。