You have to establish the age of one applicant as bound to a variable so that you<br>can ascertain this being equal to the age of all Applicants.<br><br>rule "age-2"<br>when<br> $list : List( size > 0 ) # ensure non-empty so that get(0) doesn't NPE<br>
forall( Applicant( $age : age == ( ((Applicant)$list.get(0)).getAge() ) ) from $list )<br>then<br> System.out.println( "success" );<br>end<br><br><div class="gmail_quote">On 15 September 2010 09:52, tushmish <span dir="ltr"><<a href="mailto:Tushar.Mishra@lntinfotech.com">Tushar.Mishra@lntinfotech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
rule "age"<br>
when<br>
$list : List();<br>
forall( $app : Applicant( $age : age) from $list<br>
Applicant( this == $app, age == $age ) );<br>
then<br>
System.out.println("success" );<br>
end<br>
<br></blockquote><div><br>It's noteworthy that this rule would fire if you insert all Applicant objects that are in the List as 1st order facts. What is does is<br><br> forall( $app | $app in List &<br> forall ( $f | $f in WM & $f instanceof Applicant & $f == $app & $f.age == $app.age ) )<br>
<br>where the inner "forall" is implied by the general fact matching algorithm. The last term of the inner conjunction is redundant as we have established the identity by $f == $app - the pattern just matches all list elements with themselves.<br>
<br>-W<br><br><br><br><br><br> </div><div><br> </div></div><br>