java - 检查列表的所有元素(Drools 专家)

标签 java rules drools decision-tree rule-engine

我正在尝试在 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/

相关文章:

java - Drools:字符串全局变量的奇怪行为

java - 在 Tomcat 上部署 war 文件并在没有项目名称的情况下运行

r - 将所有逻辑规则与矩阵并按相同顺序匹配

java - Spring 拦截器不发射

php - 重写站点上的 URL 地址

python - Django 规则对象权限

java - 流口水如何获取列表中的最后一个元素

java - 如何让 Drools (Kie Session) 在 Netbeans Web 项目(无 Maven)中运行?

java - 安卓 : How to read file in bytes?

即使不需要 xserver,Java 应用程序也会抛出 `Gtk-WARNING **: cannot open display:`