我的规则如下:
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 Objects,但如何获得empnames
列表?
答案 0 :(得分:0)
最好将简单的数据处理算法实现为它们所属的类中的方法。为此编写规则是可能的,但这是错误的工具。
rule "employees"
when
Company( $emps: employees )
accumulate( Employee( $name: empname ) from $emps;
$name: collectList( $name ) )
then
... use List $name
end