检查列表的所有元素(Drools Expert) [英] Check all elements of a list (Drools Expert)
问题描述
我正在尝试在Drools Expert中编写规则。在规则的时间
部分中,我检查了 Application
对象的某些属性。该对象包含一个列表,我想检查一堆规则是否适用于此列表中SomeOtherType的所有对象。该规则仅在该约束对于该列表中的所有对象均有效时才触发。
I'm trying to write rules in Drools Expert. In the when
part of the rule, I check some properties of an Application
object. This object contains a List and I would like to check if a bunch of rules apply to all objects of SomeOtherType in this list. The rule should fire only when the constraints are valid for ALL objects in that list.
rule "Application eligible"
when
app : Application(
some constrains
& write some constraints for all objects in app.getList() (a method
that returns a List<SomeOtherType> object)
)
then
// application is eligible
end
推荐答案
如果还没有,请将所有 SomeOtherType
实例也插入工作内存中。
然后,如果要检查所有SomeOtherType是否都具有红色,请尝试执行以下操作:
Insert all your SomeOtherType
instances into the working memory too if you haven't already.
Then try something like this if you want to check that all SomeOtherType's have the color RED:
rule "Application eligible"
when
$app : Application()
forall( $x : SomeOtherType( application == $app )
SomeOtherType( this == $x, color == RED ) )
then
// application is eligible
end
这篇关于检查列表的所有元素(Drools Expert)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!