[rules-users] how is Integer converted when comparing with primitive?

Mario Fusco mario.fusco at gmail.com
Thu Sep 27 09:04:24 EDT 2012


Wolfgang,

thanks for having tried this, but following your examples I made some
further tests (on the master branch) end it seems to me that constraints in
the from lowerBound < value < upperBuond are not working at all regardless
of the fact if value is null or not.

For instance I tried

declare Cont
  val:Integer
end

rule makeFacts
salience 999999
when
then
    insert( new Cont( 2 ) );
end

rule "3 < val < 10"
when
    $c: Cont( 3 < val < 10 )
then
    System.out.println( drools.getRule().getName() + " fires" );
end 

and this last rule fires even if val is set to 2 (while it doesn't if I
rewrite the pattern as: Cont( val > 3 && < 10 ) ). I am just guessing now,
but it seems to me that instead of testing lowerBound < value < upperBuond
it is actually only checking  lowerBound < upperBuond because the only way
to avoid that the rule fires is to write a pattern like: Cont( 11 < val < 10
)

Moreover I cannot find any doc stating that we are supporting that format of
constraints, neither any test in our code base using them. Can you confirm
that this constraint format should be supported by Drools? If so I will try
to fix it asap.

Mario



--
View this message in context: http://drools.46999.n3.nabble.com/how-is-Integer-converted-when-comparing-with-primitive-tp4019975p4020013.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list