[rules-users] Trying to compare variables of two objects, not working. (compiles, but not desired result)

Wolfgang Laun wolfgang.laun at gmail.com
Fri Apr 13 15:23:18 EDT 2012


On 13/04/2012, Vincent Legendre <vincent.legendre at eurodecision.com> wrote:
> Le 13/04/2012 10:46, Wolfgang Laun a écrit :
>> 5.3.0 and 5.4.0.Beta2: Comparing int and Integer fails unless the
>> traditional (up to 5.1.1) "return value" construct - parentheses
>> around the expression - is used:
>>
>>   lineItemId == ($lineItem.getID())  // OK
>>   lineItemId == ($id)   // OK with $id bound as LineItem( $id: ID>  0 )
>
> Do you mean that this is a new feature since 5.3 and comparing Integer
> worked with values prior to this version ?

5.1.1 didn't return equal unless "return value" was used. My remark
was meant to indicate that 5.2.0 and later were trying to do away with
the necessity for return value.


> This is confusing, as I really though that drools uses equals instead of
> == for String and all "primitives as Object" like Long, Integer and so
> on ...
> And this is strange, as in Java, == works with values for Integer, and
> drools is in java ...
> And I never faced this problem before, and I am pretty sure that I did
> use Long in tests ... well in fact I was sure before this mail, less now ...
>
> Can you develop more on why this is done this way, and why this is not
> behaving like java ?

Even in Java you can come across some strange results when using "=="
between Integer and Integer. There's a difference between Integers
between -128 and 127 and those outside this range.

-W

>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list