[rules-users] Test for element in an arraylist

Bojan Janisch bojan.janisch at scai.fraunhofer.de
Wed Jan 16 11:41:34 EST 2013


Hello everyone,

I got a problem with my rule. To keep it 
simple here's the code:

global java.util.ArrayList odmList

rule "Combine ODMAnswers"

    when        	
        $a1:ODMAnswer(  )
        $a2:ODMAnswer(  )
        
        eval(odmList contains $a1 && odmList contains $a2)  
    then
        ODMAnswer answer = new ODMAnswer(  );
        odmList.add(answer);
        odmList.remove($a1);
        odmList.remove($a2);
end


So why do I get an error message looking like this:
Rule Compilation error Syntax error on token "contains", invalid AssignmentOperator
odmList.$a2 cannot be resolved or is not a field
Syntax error on token "contains", . expected

Thanks to everyone who reads this.

Bojan


More information about the rules-users mailing list