[rules-users] rule parse error for null check

Neel neeleshdev at yahoo.co.in
Mon Aug 29 07:58:40 EDT 2011


Thanks! Wolfgang

--- On Sun, 28/8/11, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

From: Wolfgang Laun <wolfgang.laun at gmail.com>
Subject: Re: [rules-users] rule parse error for null check
To: "Rules Users List" <rules-users at lists.jboss.org>
Date: Sunday, 28 August, 2011, 11:33 PM

See JBRULES-3064, dialect "mvel" flouts generic parameters.

If you omit "<String,Integer>" after "new HashMap" all is well. Of course, this is another MVEL bug or restriction - who knows.


But don't try to work around this by 

then
   if($u.subjectGradeMap == null){
      $u.subjectGradeMap = new HashMap/*<String,Integer>*/();

   }

You'll just run into another MVEL bug.

-W



2011/8/28 Neel <neeleshdev at yahoo.co.in>


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


_______________________________________________

rules-users mailing list

rules-users at lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users





-----Inline Attachment Follows-----

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110829/3ade4668/attachment.html 


More information about the rules-users mailing list