code: 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);
          }
      }
docs: Method to check if a currency is compatible with this amount instance.
  
  @param amount       The monetary amount to be compared to, never null.
  @param currencyUnit the currency unit to compare, never null.
  @throws MonetaryException If the amount is null, or the amount's {@link CurrencyUnit} is not
  compatible, meaning has a different value of
  {@link CurrencyUnit#getCurrencyCode()}).