[rules-users] BigDecimal is Int or Long?

Jason Partyka Jason.Partyka at hightowerinc.com
Wed Mar 26 16:55:55 EDT 2008


I just came across this the other day, when I was importing rules generated by a lookup table. I wasn't able to fully resolved it, but I had partially resolved it by formatting the cells to have a decimal point.

________________________________________
From: rules-users-bounces at lists.jboss.org [rules-users-bounces at lists.jboss.org] On Behalf Of ST [super_thunder2 at hotmail.com]
Sent: Wednesday, March 26, 2008 3:44 PM
To: rules-users at lists.jboss.org
Subject: [rules-users] BigDecimal is Int or Long?

Hi,

There is a situation where BigDecimal is returned from a function.  But when
this BigDecimal is included as one of the conditions in a rule.  I get a
ClassCastException about trying to cast to Integer.  Below is an example that
reproduces this error.  Is this an expected behavior?  If so, is there any way
to avoid the error?



package com.sample

import java.math.BigDecimal


rule "init1"
salience 1000
        when
          num : BigDecimal() from getBigDecimal("1")
        then
          System.out.println(num.compareTo(new BigDecimal("0")));
end


function BigDecimal getBigDecimal(String value) {
  return new BigDecimal(value);
}



_______________________________________________
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