[rules-users] Constants and BigDecimals

Wolfgang Laun wolfgang.laun at gmail.com
Fri Oct 8 08:45:51 EDT 2010


I should have added that an imported variable cannot be used just like a
literal;
it'll have to be parenthesized, e.g.
    $sale : Sale( amount > (MAX_AMOUNT) )

Another way of getting named constants would be through one fact (or a few
facts)
containing the values as members. Then you could write
   SaleParams( $ma : maxAmound )
   $sale : Sale( amount > $ma )

-W


On 8 October 2010 13:17, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

> You could do public final static MAX_AMOUNT in some class foo.Bar and then,
> in DRL:
>    import function foo.Bar.*;
> and use MAX_AMOUNT as usual.
>
> -W
>
>
> On 8 October 2010 12:52, Evert Penninckx <evert.penninckx at gmail.com>wrote:
>
>>
>> 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.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101008/b25cb192/attachment.html 


More information about the rules-users mailing list