[rules-users] Re: 4.0 Language Updates
Edson Tirelli
tirelli at post.com
Mon Jul 9 14:04:47 EDT 2007
Ronald,
Take a look at the class and it will be easy to understand:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java
!= for big decimals is translated to
return ! val1.equals( val2 );
In both cases, it is delegating to the object equals() method, that in
case of BigDecimal, compare values, not references ( identity ).
[]s
Edson
2007/7/9, Ronald R. DiFrango <ron.difrango at gmail.com>:
>
> On a similiar note what if you do:
>
> BigDecimal != 0
>
> On 7/9/07, Ronald R. DiFrango <ron.difrango at gmail.com > wrote:
> >
> > Thanks Edson!
> >
> > Does the equals methods compare the underlying values or the object
> > references?
> >
> > On 7/9/07, Edson Tirelli < tirelli at post.com> wrote:
> > >
> > > Ronald,
> > >
> > > Yes, this is one way (I would say probably the preferred way) of
> > > doing it.
> > > For BigDecimals, drools will use equals() method.
> > >
> > > Look at the BigDecimalFactory class for details.
> > >
> > > []s
> > > Edson
> > >
> > > 2007/7/9, Ronald R. DiFrango <ron.difrango at gmail.com >:
> > > >
> > > > OK, I think I found it and here is what the rule could look like:
> > > >
> > > > rule "Repayment Code Requires Approval"
> > > > salience 60
> > > >
> > > > when
> > > > repaymentCode : RepaymentCode( code == "MD", matchApprv ==
> > > > "Y" )
> > > > mdOutput : ModelDiscrepancyOutput( $amt1 : sumRTVQty,
> > > > sumCmAndRnr == $amt1)
> > > > then
> > > > System.out.println("Repayment Code Requires Approval");
> > > > processMDAdjustments( drools.getWorkingMemory().getQueryResults( "MD Adjustments" ),
> > > > StatusConstants.APPROVAL);
> > > > System.out.println("mdOutput: " + mdOutput);
> > > > end
> > > >
> > > > Now my question is, how does Drools handle these objects and the
> > > > comparison because the underlying objects are BigDecimal?
> > > >
> > > > On 7/9/07, Ronald R. DiFrango < ron.difrango at gmail.com> wrote:
> > > > >
> > > > > All,
> > > > >
> > > > > I have the following rule:
> > > > >
> > > > > rule "Repayment Code Requires Approval"
> > > > > salience 60
> > > > >
> > > > > when
> > > > > repaymentCode : RepaymentCode( code == "MD", matchApprv ==
> > > > > "Y" )
> > > > > mdOutput : ModelDiscrepancyOutput( $amt1 : sumRTVQty,
> > > > > $amt2 : sumCmAndRnr)
> > > > > eval($amt1.doubleValue() == $amt2.doubleValue())
> > > > > then
> > > > > System.out.println("Repayment Code Requires Approval");
> > > > > processMDAdjustments(drools.getWorkingMemory().getQueryResults(
> > > > > "MD Adjustments" ), StatusConstants.APPROVAL);
> > > > > System.out.println("mdOutput: " + mdOutput);
> > > > > end
> > > > >
> > > > > If I remember correctly, there was going to be an update to the
> > > > > rules language that would allow me to eliminate the eval. Is this true and
> > > > > if so what is the syntax that accomplishes this?
> > > > >
> > > > > Ron
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > rules-users mailing list
> > > > rules-users at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/rules-users
> > > >
> > > >
> > >
> > >
> > > --
> > > Edson Tirelli
> > > Software Engineer - JBoss Rules Core Developer
> > > Office: +55 11 3529-6000
> > > Mobile: +55 11 9287-5646
> > > JBoss, a division of Red Hat @ www.jboss.com
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> > >
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070709/ba2b5a5f/attachment.html
More information about the rules-users
mailing list