如何从结果/右侧获取条件/左侧定义的所有流口水变量的列表?
How to get a list of all drools variables defined in condition / left hand side from inside the consequence / right hand side?
我们需要知道在规则的条件部分定义了哪些变量,并用它们执行一些操作。有什么方法可以找回它们吗?
示例(注意,我只是编造了这个虚拟代码,所以不保证正确性):
rule DummyRule
when
$player: Player()
$team: Team(teamId == $player.teamId)
then
$player.setDummy(true);
[for all vars in when-part, e.g. $player, $team]
someGlobal.processVar($var)
[endFor]
end
我需要的是[]中的部分 - 如何确定when-部分中检索到的变量?我在文档中找不到任何内容,所以也许有人可以在这里提供帮助。
此致,
凯
RHS 中有一个名为 kcontext
的神奇变量,类型为 RuleContext
。也许你可以从那里以某种方式得到它们。
我们需要知道在规则的条件部分定义了哪些变量,并用它们执行一些操作。有什么方法可以找回它们吗?
示例(注意,我只是编造了这个虚拟代码,所以不保证正确性):
rule DummyRule
when
$player: Player()
$team: Team(teamId == $player.teamId)
then
$player.setDummy(true);
[for all vars in when-part, e.g. $player, $team]
someGlobal.processVar($var)
[endFor]
end
我需要的是[]中的部分 - 如何确定when-部分中检索到的变量?我在文档中找不到任何内容,所以也许有人可以在这里提供帮助。
此致, 凯
RHS 中有一个名为 kcontext
的神奇变量,类型为 RuleContext
。也许你可以从那里以某种方式得到它们。