Prefer Money.zero over Money.of(currency, 0)

In the case where currency has a zero scale (i.e. JPY),
Money.of(currency, 0) throws ArithmeticException because the second
argument is handled as a double, and JPY (for example) does not allow
decimal precision, even if the decimal is zero.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129023540
This commit is contained in:
Chris Tingue 2016-08-01 13:59:50 -07:00 committed by Justine Tunney
parent 3f471a32e2
commit b2d5108c0c

View file

@ -56,7 +56,7 @@ public final class TldSpecificLogicProxy {
* Returns the total cost of all fees for the event.
*/
public Money getTotalCost() {
Money result = Money.of(currency, 0);
Money result = Money.zero(currency);
for (Fee fee : fees) {
result = result.plus(fee.getCost());
}