drools coercion fail somethings -


according documentation,"coercion in favor of field type , not value type"

i tried , it's not true.

the rule:

rule "get event field " when     m : message( geteventfield("bigdecimalb") > "7.5" )     system.out.println( "hit" );  end 

the message class:

public  class message {      private map<string, object> map = new hashmap<string, object>();      public object geteventfield(string key) {         object object = map.get(key);         if (object != null) {             //class=java.math.bigdecimal in test             system.out.println("geteventfield, fieldname=" + key + ", class=" + object.getclass().getcanonicalname());         }         return object; }  //setter , getter } 

and test:

        string str = "{\"bigdecimalb\":10.2}";         map<string, object> map = json.parseobject(str);          message message = new message();         message.setmap(map);         ksession.insert(message);         ksession.fireallrules(); 

in cases, "bigdecimal comparation" , 10.2 > 7.5, prints 'hit'.

but can fail , not print 'hit'.

i thinks it's because coercion not sucess , "string comparation".it's hard reproduce. i'm totally confused , don't know why.

i'm using drools-6.2.0-final , alibaba's fastjson(https://github.com/alibaba/fastjson).

thank much.

if have method declaration this:

 public object getfoofield(string key) 

what think stupid computer program might think return type of method?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -