[rules-users] comparisons on Java primitive wrapper class types

wasabifan bryan.rickman at kewill.com
Wed Mar 28 16:19:52 EDT 2007


class MyObject {
  private Integer used;
  private Integer notUsed;
  // public setters/getters...
}

rule "1"
  when
    MyObject(used == 1)
  then
    // do something
end

rule "2"
  when
    UnrelatedObject(data == 5)
    MyObject(notUsed == 2)
  then
    // do something else
end

Basically, I am trying to create JUnit test cases to test each of the rules
functionality.  So I would instantiate and object, set the required data to
fire a rule, assert the object and fire all rules.  So when setting
MyObject.used = 1, then asserting that fact...it appears that rule 2 would
complain that notUsed is null (even though I do not have an asserted fact
where UnrelatedObject(data == 5).

Does this make sense?  I know this is sort of pseudo code thrown together
quickly, but I think that explains what I was experiencing.  If not, I can
go back to get some of the actual code, but that would be much longer.

Thanks,
Bryan


Edson Tirelli-3 wrote:
> 
>    Brian,
> 
>    Can you please provide one example for us to understand better the
> case?
> 
>     Thank you,
>      Edson
> 
> 2007/3/28, wasabifan <bryan.rickman at kewill.com>:
>>
>>
>> In creating a list of rules, I noticed when adding facts to my working
>> memory
>> it may cause errors if Integer or Long values are null (as they are
>> attempting to do comparisons on null objects...even if other conditions
>> previously listed in that particular rule eliminate this fact from that
>> particular conflicting rule), however, I have not noticed this behavior
>> for
>> null String objects.  Is this the expected behavior, or should they be
>> defaulting to 0 in the comparisons (much like I am assuming the Strings
>> must
>> be defaulting to empty Strings)?
>>
>> Thanks for any clarification.  I am using 3.1M1 if that is relevant as
>> well.
>>
>> Bryan
>> --
>> View this message in context:
>> http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9718377
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
> 
> -- 
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3124-6000
>   Mobile: +55 11 9218-4151
>   JBoss, a division of Red Hat @ www.jboss.com
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9721783
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list