0
rule "typeChild should be unique"
when
RuleActivator(targetMessage == "QWERTY")
$o: Parent()
$o2: ListGeneric(typeChild != null) from $o.getDetails()
$o3: ListGeneric(typeChild != null && (typeCode == $o2.typeCode)) from $o.getDetails()
then
insert(new ValidationError(ValidationUtil.qualifyField($DECL_ROOT, $o3, "typeChild"), "UNIQUE"));end
如果ListGenric中的任何typeChild是相同的,我想觸發一條規則。 細節存在於父列表()豆這樣的:Drools列表迭代問題
protected List<ListGeneric> details;
而且也有其getter和setter方法。 現在我得到的問題是,它開始比較表格中列表中的第一個項目,這總是相同的。因此,它每次都觸發規則。 那麼,我如何才能在它中插入計數,就好像它比較兩次那麼應該觸發規則? 或者如果有其他更好的解決方案,請推薦。
非常感謝兄弟,這完美地解決了我的問題。對不起,我缺乏2點的聲望,所以不能投你的答案。 :P –