通过列表值和多个条件来规划事实规则

时间:2015-07-01 07:33:24

标签: drools

我正在尝试编写一条规则,将事实列表值与多条件规则进行比较

rule: only valid legislations
when
 fact:Fact (legislationList == ('L1' && 'L2') OR 'L3')
then
 fact.printMessage();
end

ie. if fact.legislationList={'L1', 'L2') then fire
    if fact.legislationList={'L1', 'L4') then dont fire

我看着'来自'条款,但不清楚这将如何解决我的问题。

是否有一些伏笔的方法/解决方案可以帮助我?

感谢

-lp

1 个答案:

答案 0 :(得分:3)

假设legisList是List< String>,那么你可以使用Drools的'contains'运算符:

rule: only valid legislations
when
    fact:Fact ((legislationList contains "L1" && legislationList contains "L2") || legislationList contains "L3" )
then
    fact.printMessage();
end

您可以稍微缩写语法,但我想要明确。

希望它有所帮助,

相关问题