没有条件元素,官方示例:
rule "no CEs"
when
// empty
then
... // actions (executed once)
end
// The above rule is internally rewritten as:
rule "eval(true)"
when
eval( true )
then
... // actions (executed once)
end
如果有多条规则元素,默认它们之间是“和”的关系,也就是说必须同时满足所有的条件元素才会触发规则。官方示例:
rule "2 unconnected patterns"
when
Pattern1()
Pattern2()
then
... // actions
end
// The above rule is internally rewritten as:
rule "2 and connected patterns"
when
Pattern1()
and Pattern2()
then
... // actions
end
和“or”不一样,“and”不具有优先绑定的功能。因为声明一次只能绑定一个FACT对象,而当使用and时就无法确定声明的变量绑定到哪个对象上了。以下代码会编译出错。
| $person : (Person( name == “Romeo” ) and Person( name == “Juliet”)) |
QQ技术交流2群:715840230
CSDN学院:《Drools7规则引擎进阶教程》
CSDN学院:《Drools7规则引擎入门教程》
CSDN学院:《Drools7系列优惠套餐》
关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台
除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接
]]>