[rules-users] Constants and BigDecimals

Evert Penninckx evert.penninckx at gmail.com
Fri Oct 8 06:52:55 EDT 2010


Hi 

I've got the following rule:

when
  $sale : Sale( amount > 300 )
then
  modify($sale) { amount = 300; }
end

First problem: I don't like putting the constant value "300" two times in my
rule.

Second problem: amount is a BigDecimal. I read that mvel2 supports
BigDecimal literals like 300.00B, but drools won't compile this.

An ideal solution would look like something like this:

when
  $maxAmount : 300.00B
  $sale : Sale( amount > $maxAmount )
then
  modify($sale) { amount = $maxAmount; }
end


1. Is it possible to attribute values to a variable?

2. If not, is it possible to use mvel's BigDecimal support?  Because amount
> 300.00B says a lot more than eval(amount.compareTo(new
BigDecimal("300.00")) > 0).



Evert
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Constants-and-BigDecimals-tp1664852p1664852.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list