我正在处理ilog规则。我想验证对象数组列表中的一个字段。
比如
class Company {
List<Employee> employee;
}
class Employee {
String Name;
int age;
}
在这里,我想验证年龄字段不是负数。我有公司对象作为输入参数传递,
definitions
set 'Company' to 'The Company to validate' ;
set 'Employees' to employee working for 'Company'
现在,我如何迭代数组列表中的employee并检查年龄验证。
使用'in'BAL构造将集合中的单个员工绑定到定义语句中的变量,然后为该员工编写验证规则。
请参阅您的IBM ODM版本的知识中心/信息中心,例如:
IBM Operational Decision Manager 8.6.0>Operational Decision Manager版本8.6>决策服务器规则>参考>规则设计器参考>规则语言>业务操作语言(BAL)>BAL构造>在中
你可以试试这样的东西:
definitions
set 'employee' to an employee in the employees of 'the company' ;
if
the age of employee is less than 0
then
print "Age of employee " + the name of employee + "' is negative: " + the age of employee ;
else
print "Age of employee " + the name of employee + "' is OK: " + the age of employee ;