流口水规则中有多个布尔条件? [英] Multiple boolean conditions in a rule in drools?
问题描述
我创建了一个规则,其何时条件如下:-
I have created a rule whose "when" condition is as follows :-
when
$map: Map(this["key1"].equals("value1")) and Map(this["key2"].equals("value2"))
then
...
上述条件正常。
现在如何在规则中添加多个布尔条件?
例如上面的规则可以概括为:a和b
,因此,如果我要创建规则:(a和b)或c,那么实际的drl语法是什么。
我是流口水的新手,所以请帮助我了解规则(a和b)或c的语法。
The above condition is working fine. Now how do I add multiple boolean conditions in a rule? For eg. The above rule could be summarized as : a and b so if I want to create a rule : (a and b) or c then what would be actual drl syntax for it. I am new to drools so kindly help me with the syntax of the rule (a and b) or c.
我确实创建了语法
when
$map: Reindexing((Map(this["key1"].equals("value1")) and Map(this["key2"].equals("value2"))) or Map(this["key3"].equals("value3")))
then
但是我遇到了以下异常
错误消息:消息[id = 1,级别= ERROR,
路径= mapIterationRules.drl,行= 13,列= 0文本= [ERR 101]行
13:21输入'('在规则中没有可行的选择第一条规则]
Error Messages: Message [id=1, level=ERROR, path=mapIterationRules.drl, line=13, column=0 text=[ERR 101] Line 13:21 no viable alternative at input '(' in rule "first rule"]
谢谢
推荐答案
弄清楚上述规则的语法,感谢劳恩和托尼的帮助。
Figured out the syntax for the above rule. thanks laune and toni for the help.
这是语法
when
$map: Map( this["data1"].equals("dataOutput1") ) || Map( this["data2"].equals("dataOutput2") && this["data3"].equals("dataOutput3") )
在同一括号内时,不需要再次键入类名。
when inside the same bracket, it is not required to type the class name again.
这篇关于流口水规则中有多个布尔条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!