检查列表的所有元素(Drools Expert)
我正在尝试在 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尚未将所有
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:
如果您想避免必须按照 Geoffry 的建议使用collect 将对象插入工作内存,我还发现了另一种 hack-y 方法来做到这一点:
I also found another kind of hack-y way to do this if you want to get around having to insert your object into working memory using collect as Geoffry suggested: