我正在尝试在 Drools Expert 中编写规则。在规则的 when
部分,我检查了 Application
对象的一些属性。该对象包含一个列表,我想检查一组规则是否适用于该列表中 SomeOtherType 的所有对象。仅当约束对该列表中的所有对象都有效时,才应触发该规则。
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 的颜色是否为红色,请尝试这样的操作:
rule "Application eligible"
when
$app : Application()
forall( $x : SomeOtherType( application == $app )
SomeOtherType( this == $x, color == RED ) )
then
// application is eligible
end
关于java - 检查列表的所有元素(Drools 专家),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5106500/