0

我的规则如下:

when
  C : Company()
  $empname : List() collect from (Employee($empname : empname) from C.employees)
then
  System.out.println($empname);

对应的类:

public class Company {
  private List<Employee> employees;
  private Stringlocation;
}

public class Employee {
  private String empname;  
  private int empid;
}

使用我的代码,我只获取 Employee 对象,但如何获取empnames列表?

4

1 回答 1

0

最好将简单的数据处理算法实现为它们所属的类中的方法。为此编写规则是可能的,但它是错误的工具。

rule "employees"
when
   Company( $emps: employees )
   accumulate( Employee( $name: empname ) from $emps; 
               $name: collectList( $name ) )
then
   ... use List $name
end
于 2017-12-14T17:52:02.310 回答