[jboss-jira] [JBoss JIRA] (DROOLS-3527) executable-model fails to compare BigDecimal

Toshiya Kobayashi (Jira) issues at jboss.org
Thu Jan 17 02:28:01 EST 2019


Toshiya Kobayashi created DROOLS-3527:
-----------------------------------------

             Summary: executable-model fails to compare BigDecimal
                 Key: DROOLS-3527
                 URL: https://issues.jboss.org/browse/DROOLS-3527
             Project: Drools
          Issue Type: Bug
          Components: executable model
    Affects Versions: 7.16.0.Final
            Reporter: Toshiya Kobayashi
            Assignee: Luca Molteni


When executable-model builds BigDecimal constraint, BigDecimal(long) constructor is used hence fails to compare at runtime.

It generates source code like this:
{code:java}
public class Rules64ef7d59a364454aa08fdda838c67ad1RuleMethods0 {

    /**
     * Rule name: R1
     */
    public static org.drools.model.Rule rule_R1() {
        final org.drools.model.Variable<com.sample.Customer> var_$customer = D.declarationOf(com.sample.Customer.class,
                                                                                             "$customer");
        org.drools.model.Rule rule = D.rule("com.sample",
                                            "R1").build(D.pattern(var_$customer).expr("$expr$1$",
                                                                                      (_this) -> org.drools.modelcompiler.util.EvaluationUtil.equals(org.drools.modelcompiler.util.EvaluationUtil.toBigDecimal(_this.getRate()),
                                                                                                                                                     org.drools.modelcompiler.util.EvaluationUtil.toBigDecimal(12.111)),
                                                                                      D.alphaIndexedBy(java.math.BigDecimal.class,
                                                                                                       org.drools.model.Index.ConstraintType.EQUAL,
                                                                                                       0,
                                                                                                       _this -> _this.getRate(),
                                                                                                       new java.math.BigDecimal("12.111")),
                                                                                      D.reactOn("rate")),
                                                        D.execute(() -> {
            System.out.println("hello");
        }));
        return rule;
    }
}
{code}




--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list