[英]Drools : How to update Arraylist?
I am stuck in middle of something, I am trying to update Object in drools session as code given, but it could not gets update. 我被困在中间,我尝试在给定代码的drools会话中更新Object,但是无法更新。
rule "Abc"
salience 1
when
a:A()
then
ArrayList al = a.getAllItems();
for(int i =0;i<a.getAllItems().size;i++)
{
B b = new B();
al.add(b);
}
a.setAllItems(al);
update(a);
end
Any suggession or help from you will help me to go ahead.... 您的任何建议或帮助都会帮助我前进。
Thanks in advance 提前致谢
I'd started with simplified code like below: 我从下面的简化代码开始:
rule "Abc"
salience 1
when
a:A()
then
modify($a) { myMethod(); }
end
public class A {
public void myMethod() {
for(Object obj : getAllItems()) {
B b = new B();
// ...
// ...
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.