@Test public void testCheckAmountParameter() { CurrencyUnit dollar = Monetary.getCurrency("USD"); CurrencyUnit real = Monetary.getCurrency("BRL"); checkAmountParameter(FastMoney.of(0, "USD"), dollar); expectThrows(MonetaryException.class, () -> checkAmountParameter(FastMoney.of(0, "USD"), real)); }
public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) { requireNonNull(amount, "Amount must not be null."); final CurrencyUnit amountCurrency = amount.getCurrency(); if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) { throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency); } }
MoneyUtils { public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) { requireNonNull(amount, "Amount must not be null."); final CurrencyUnit amountCurrency = amount.getCurrency(); if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) { throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency); } } }
MoneyUtils { public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) { requireNonNull(amount, "Amount must not be null."); final CurrencyUnit amountCurrency = amount.getCurrency(); if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) { throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency); } } private  MoneyUtils(); }
MoneyUtils { public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) { requireNonNull(amount, "Amount must not be null."); final CurrencyUnit amountCurrency = amount.getCurrency(); if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) { throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency); } } private  MoneyUtils(); static BigDecimal getBigDecimal(long num); static BigDecimal getBigDecimal(double num); static BigDecimal getBigDecimal(Number num); static BigDecimal getBigDecimal(Number num, MonetaryContext moneyContext); static MathContext getMathContext(MonetaryContext monetaryContext, RoundingMode defaultMode); static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit); static void checkNumberParameter(Number number); static String replaceNbspWithSpace(String s); }
MoneyUtils { public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) { requireNonNull(amount, "Amount must not be null."); final CurrencyUnit amountCurrency = amount.getCurrency(); if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) { throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency); } } private  MoneyUtils(); static BigDecimal getBigDecimal(long num); static BigDecimal getBigDecimal(double num); static BigDecimal getBigDecimal(Number num); static BigDecimal getBigDecimal(Number num, MonetaryContext moneyContext); static MathContext getMathContext(MonetaryContext monetaryContext, RoundingMode defaultMode); static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit); static void checkNumberParameter(Number number); static String replaceNbspWithSpace(String s); static final String NBSP_STRING; static final String NNBSP_STRING; static final char NBSP; static final char NNBSP; }