[rules-users] rule parse error for null check

Neel neeleshdev at yahoo.co.in
Sun Aug 28 09:53:20 EDT 2011


Hi,I'm using drools-5.3.0.Beta1. I've following rule file:
import java.util.*;

declare Student
   name : String @key
   subjectGradeMap : HashMap   
end
 
rule "Subject grade points"
dialect "mvel"
when
   $u : Student()
then
   if($u.subjectGradeMap == null)
   {
      $u.subjectGradeMap = new HashMap<String,Integer>();
   }
   $u.subjectGradeMap["CompSc"] += 100;
   System.out.println("Marks added");
end
I get following error while rule compilation:Unable to Analyse Expression if($u.subjectGradeMap == null);
   {
      $u.subjectGradeMap = new HashMap<String,Integer>();
   };
   $u.subjectGradeMap["CompSc"] += 100;
   System.out.println("Marks added");:
[Error: was expecting type: java.lang.Object; but found type: <Unknown>]
[Near : {... if($u.subjectGradeMap == null) ....}]
             ^
[Line: 1, Column: 1] : [Rule name='Subject grade points']

Please let me know if this is correct usage in the above scenario.
Thanks,Neel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110828/fc3a228f/attachment.html 


More information about the rules-users mailing list