在我的 drools 决策表中,我想在条件单元格中保留 getter 或函数调用,以便条件将根据来自该 getter 或函数的值进行评估。 即对于 $param,我希望单元格评估 getter 调用中的参数值。然后评估条件。
我将条件保留为 $analytics.getProp1() <= ($param) Now for this param, I want the condition cell to get the value from a function (getter call) like this $analytics.getProp2(). So that the actual evaluation will be $analytics.getProp1() <= $analytics.getProp2()
在所附示例中,我尝试从 getProp2() 获取值并将其用于参数。 正确的做法应该是什么。
Drools 将解释用于生成规则的行中的表达式。
| DESCRIPTION | CONDITION | ACTION |
| | $analytics: MyAnalytics() |
| | prop1 <= $1 | $analytics.setSomething($1) |
|-------------|---------------------------|-----------------------------|
| Example1 | 5 | 500 |
| Example2 | $analytics.getProp2() | $analytics.getProp1() |
我认为,但我手头没有 Drools 解释器来确认,您甚至不需要在规则生成行中显式包含
$analytics
位。这是因为我们有效地生成了具有 DRL 条件 $analytics: MyAnalytics( prop1 <= prop2 )
的规则,它不需要任何对父对象的引用:
| DESCRIPTION | CONDITION | ACTION |
| | $analytics: MyAnalytics() |
| | prop1 <= $1 | $analytics.setSomething($1) |
|-------------|---------------------------|-----------------------------|
| Example3 | prop2 | 500 |