0
rule "Your First Rule"
no-loop
salience 10
when
$c : Company()
// $e : String()
$e : StaffException()
$r : StaffExcCode($r.getCode() == "1") from $e.getStaffException()
$y : ArrayList()
from collect (String() from $r.getStaffExc())
$ee : Staff(StaffCode not memberOf($y)) from $c.getStaffInfo()
then
//actions
System.out.println("Satisfied." + $y);
//System.out.println("Satisfied." + $ee);
末Drools的 - 如何获得的String []从ArrayList中收集
我的ArrayList $ y和希望产生一个String []数组作为的memberOf的条件来使用。如何才能实现这一转变?
这是在演示中使用的类: 类StaffExcCode:
public class StaffExcCode {
private String StaffExc;
private String code;
public StaffExcCode(String StaffExc, String code) {
this.StaffExc = StaffExc;
this.code = code;
}
/* ignore the get and set */
}
类StaffException:
public class StaffException {
private List<StaffExcCode> exc;
/* ignore the get and set */
}
一流的工作人员:
public class Staff {
private String StaffCode;
private String StaffName;
private int StaffAge;
/* ignore the get and set */
}
类公司:
public class Company {
private int CompanyCode;
private String CompanyName;
private int StaffNumber;
private List<Staff> StaffInfo;
/* ignore the get and set */
}
我会尝试重写规则,以便它能够正常工作,但是由于您发布的规则的不完整和不一致的片段,所以这是不可能的。编辑,提供有关相关课程和相关领域的精确类型信息。 – laune
Updated ..谢谢你的帮助。 – Calvin