流口水规则具有列表值和多个条件
drools rule for fact with list values and multiple conditions
我正在尝试编写一个将事实列表值与多条件规则进行比较的规则
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
我查看了 'from' 条款,但不清楚这将如何解决我的问题。
有什么巫术method/solution可以帮助我吗?
谢谢
-lp
假设 legislationList 是一个 List,那么您可以使用 Drools 的 'contains' 运算符:
rule: only valid legislations
when
fact:Fact ((legislationList contains "L1" && legislationList contains "L2") || legislationList contains "L3" )
then
fact.printMessage();
end
您可以稍微缩短语法,但我想明确一点。
希望对您有所帮助,
我正在尝试编写一个将事实列表值与多条件规则进行比较的规则
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
我查看了 'from' 条款,但不清楚这将如何解决我的问题。
有什么巫术method/solution可以帮助我吗?
谢谢
-lp
假设 legislationList 是一个 List
rule: only valid legislations
when
fact:Fact ((legislationList contains "L1" && legislationList contains "L2") || legislationList contains "L3" )
then
fact.printMessage();
end
您可以稍微缩短语法,但我想明确一点。
希望对您有所帮助,