FindBugs is giving me a warning about the following line, where invoiceNumber
is an Integer
object:
text.append(String.format("%010d-", (invoiceNumber == null) ? 0 : invoiceNumber));
The warning is: "Boxed value is unboxed and then immediately reboxed"
Now I think I understand (un)boxing, but I can't see how you would do the same thing without getting the warning?
I have found that I can get rid of the warning using the following code instead, but this seems more long-winded:
int invNo = (invoiceNumber == null) ? 0 : invoiceNumber;
text.append(String.format("%010d-", invNo));
Can someone show me what is the 'correct' way to do the above?
BTW, I've looked at the related questions and I understand what was going on with them, but this doesn't seem to match any of those.