code: public static BigMoney of(CurrencyUnit currency, BigDecimal amount) {
          MoneyUtils.checkNotNull(currency, "Currency must not be null");
          MoneyUtils.checkNotNull(amount, "Amount must not be null");
          if (amount.getClass() != BigDecimal.class) {
              BigInteger value = amount.unscaledValue();
              if (value == null) {
                  throw new IllegalArgumentException("Illegal BigDecimal subclass");
              }
              if (value.getClass() != BigInteger.class) {
                  value = new BigInteger(value.toString());
              }
              amount = new BigDecimal(value, amount.scale());
          }
          return new BigMoney(currency, amount);
      }
docs: Obtains an instance of {@code BigMoney} from a {@code BigDecimal}.
  <p>
  This allows you to create an instance with a specific currency and amount.
  The scale of the money will be that of the {@code BigDecimal}, with
  a minimum scale of zero.
  
  @param currency  the currency, not null
  @param amount  the amount of money, not null
  @return the new instance, never null
  @throws IllegalArgumentException if an invalid BigDecimal subclass has been used