• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem regarding a field of type Bigdecimal

 
Ranch Hand
Posts: 246
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I don't know if this is the right forum to post my question. If it is not, then move to the right place. I have three conditions. I have three fields of type BigDecimal.
1. If I enter $100.00 in one field, then it should show $100.00 in the second field and $75 in the third field which is working fine.
2. If I enter $0.00 in one field, then it should show $0.00 amounts in other fields which is working fine too.
3. If I enter nothing or blank, then it should show blank for all the fields based on my condition but this is not working for second and the third fields and it reads the value from the first field.

I have the following code, so please guide me in this regard.



Thank you so much for your time.

Naveen Katoch
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
authAssessedAmount is an BigInteger and comparing it to a String doesn't work.

You should really reconsider renaming the class and method. Because what is a LITI_AutoPopEsStHghEsStLOnAssdAmnt?
You can't derive that from the name. And what does action do?
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might also consider an enum for the type of Action. Or maybe putting action types into a Map. Those multiple ||s are potentially error-prone. What happens if you add "Employment" as a potential type of dispute? What happens if your dispute is about a "Company car"?
 
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Wouter and Campbell for your inputs. I will workaround. If I could not resolve this issue, then I will ask this in SCJP forum.

Thanks again,

Naveen Katoch
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nav katoch wrote:If I could not resolve this issue, then I will ask this in SCJP forum.


Why? This does not look like it has anything to do with the SCJP certification exam. Please stay in this topic with regard to this issue.
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome

nav katoch wrote:. . . I will workaround. . . .

I am sure that by "workaround" you mean you will create a good solid solution, but workaround often means a Heath Robinson sort of solution which can be brittle and introduce more errors.
 
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbell,

I have resolved the issue with the following code and set my operator to Not Populated in my rule:-



Thanks for your time. I appreciate you all.

Naveen Katoch

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got some more remarks:

(Still) the class name
Line 11: TCLog.getRuleLogger().debug((new StringBuilder("In action() method Current User is ::--> ")).append(currentUser).toString()); Why not just concatenate with +?
Line 16: Why not use this object through out the method instead of getting it constantly with dispute.getDetailForKey("LITI");
Line 18: Why declare it there when it only gets used in the if-block and gets assigned there?
Line 19: Why declare it there when it only gets used on line 36?
Line 20: Why declare it there when it only gets used on line 36?
Line 30 & 33 in if and else part are the same.
Line 34: didn't you just set that?
Line 36: you're multiplying it with 75 and then 100? Why not multiply it with 7500?
Line 42: why not chain the exceptions and retain the stacktrace?
 
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Wouter,

Thank you so much for bringing these points in my notice. I highly appreciate your time and suggestion. I will modify it accordingly.

Naveen Katoch
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.

I just thought of another remark: line 18 & 25 can be modified to use BigDecimal.ZERO.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wouter Oet wrote:Line 36: you're multiplying it with 75 and then 100? Why not multiply it with 7500?


He's not multiplying by 75 and 100, but multiplying by 75 and dividing by 100.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So multiplying by a new BigDecimal("0.75") would work just as well.
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:So multiplying by a new BigDecimal("0.75") would work just as well.

It wouldn't work as well at all. It would work better because there is only one new BigDecimal object created.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic