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 ) ; } }
Method to check if a currency is compatible with this amount instance .