I'm using JSR 354 a.k.a JavaMoney
, and I don't understand what MonetaryAmount.plus()
is supposed to do?
For all implementations of MonetaryAmount
I found, it simply returns this
. The documentation is not helpful to me:
Returns a {@code MonetaryAmount} whose value is <code>+this</code>, with rounding according to
the context settings.
This is a bit unfortunate when using Kotlin, which has operator overloading for the function plus
which maps the operator +
onto this function, where as it should map onto add
in this case.
This can be fixed:
operator fun MonetaryAmount.plus(other: MonetaryAmount) = this.add(other)
But I'm not sure onto what operator I should map the plus()
function to? UnaryPlus
?