Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonetaryAmount.stripTrailingZeros() is confusing #114

Open
marschall opened this issue Jan 6, 2019 · 3 comments
Open

MonetaryAmount.stripTrailingZeros() is confusing #114

marschall opened this issue Jan 6, 2019 · 3 comments

Comments

@marschall
Copy link
Member

javax.money.MonetaryAmount#stripTrailingZeros() is confusing for two reasons:

  • It seems to be the only method left on MonetaryAmount that operates on the number value. #getAmountWhole() has been removed and #getAmountFractionNumerator() and #getAmountFractionDenominator() have been moved to javax.money.NumberValue.
  • It assumes the implementation has an adjustable scale like BigDecimal/org.javamoney.moneta.Money. It is unspecified that should happen in cases where the scale is fixed like for org.javamoney.moneta.FastMoney.

It could either be moved to javax.money.NumberValue like #getAmountFractionNumerator() and #getAmountFractionDenominator() or a user could simply do

money.getFactory()
        .setNumber(money.getNumber().numberValueExact(BigDecimal.class).stripTrailingZeros())
        .create();
@keilw keilw added the deferred label Jan 6, 2019
@keilw
Copy link
Member

keilw commented Jan 6, 2019

That's not for now, it could be a possible deprecation / refactoring in new releases.

@keilw keilw added this to the .Next milestone Jan 6, 2019
@marschall
Copy link
Member Author

I understand that changing the ABI may not be an option.
What would be nice if we could formalise / specify the behaviour for implementations with a fixed scale.

@keilw
Copy link
Member

keilw commented Jan 8, 2019

Maybe it could be configured but only in a future version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants