I want to have a nested exists in my rule, but when I run it I get a mismatched input error. I am trying to find if, for an object with 2 lists, there exists an object in list 1 and an an object in list 2 such that they are equivalent.
Here are the relevant objects:
public class A {
List<B> bList;
List<C> cList;
}
public class B {
String name;
}
public class C {
String id;
}
(B == C if B.name == C.id)
Is there a Drools-only solution or workaround for what I want to do?
Here is my rule (causes mismatched input error).
rule "find B-C match"
when
$a: A(bList != null && cList != null)
exists $b: B(
exists $c: C($b.name == $c.id)
from $a.cList)
from $a.bList
then
System.out.println("A has a match");
// do other stuff
end
New contributor
Kaven Xiong is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.