• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem regarding a field of type Bigdecimal  RSS feed

 
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • 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
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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: 56578
172
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So multiplying by a new BigDecimal("0.75") would work just as well.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!