Static factory method for creating a new instance of {@link FastMoney}.

@param currency      The target currency, not null.
@param numberBinding The numeric part, not null.
@return A new instance of {@link FastMoney}.
168552
public static FastMoney of(NumberValue numberBinding, CurrencyUnit currency) {
        return new FastMoney(numberBinding, currency, false);
    }
476276
public RoundedMoney with(CurrencyUnit currency) {
        Objects.requireNonNull(currency, "currency required");
        return new RoundedMoney(asType(BigDecimal.class), currency, rounding);
    }
725659
@Override
    public Money add(MonetaryAmount amount) {
        MoneyUtils.checkAmountParameter(amount, this.currency);
        if (amount.isZero()) {
            return this;
        }
        return new Money(this.number.add(amount.getNumber().numberValue(BigDecimal.class)), getCurrency());
    }
936608
@Override
    public CurrencyAmount add(final CurrencyAmount money) {
        if (!money.getCurrency().equals(currency)) {
            throw new IllegalArgumentException("You cannot add " + money.getCurrency() + " with " + currency);
        }
        return new Cash(currency, BigDecimalUtil.add(amount, money.getAmount()));
    }
520924
public static BitfinexCurrencyPair of(final String currency, final String profitCurrency) {
		final String key = buildCacheKey(currency, profitCurrency);

		final BitfinexCurrencyPair bcp = instances.get(key);

		if (bcp == null) {
			throw new IllegalArgumentException("CurrencyPair is not registered: " + currency + " " + profitCurrency);
		}

		return bcp;
	}
199631
public MonetaryFormat code(int codeShift, String code) {
        checkArgument(codeShift >= 0);
        final String[] codes = null == this.codes
            ? new String[MAX_DECIMALS]
            : Arrays.copyOf(this.codes, this.codes.length);

        codes[codeShift] = code;
        return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups,
                shift, roundingMode, codes, codeSeparator, codePrefixed);
    }
304201
public static MonetaryAmountDecimalFormatBuilder of(Locale locale) {
        MonetaryAmountDecimalFormatBuilder builder = new MonetaryAmountDecimalFormatBuilder();
        builder.decimalFormat = (DecimalFormat) NumberFormat.getCurrencyInstance(locale);
        builder.locale = locale;
        return builder;
    }
637879
private void addCurrencyInfo(TypeSpec.Builder type, NumberData data) {
    addCurrencyInfoMethod(type, "getCurrencySymbol", data.currencySymbols);
    addCurrencyInfoMethod(type, "getNarrowCurrencySymbol", data.narrowCurrencySymbols);
    addCurrencyInfoMethod(type, "getCurrencyDisplayName", data.currencyDisplayName);

    MethodSpec.Builder method = MethodSpec.methodBuilder("getCurrencyPluralName")
        .addModifiers(PROTECTED)
        .addParameter(Types.CLDR_CURRENCY_ENUM, "code")
        .addParameter(PluralCategory.class, "category")
        .returns(String.class);

    method.beginControlFlow("switch (code)");
    for (Map.Entry<String, Map<String, String>> currencyMap : data.currencyDisplayNames.entrySet()) {
      String code = currencyMap.getKey();
      Map<String, String> mapping = currencyMap.getValue();
      if (mapping.isEmpty()) {
        continue;
      }
      
      method.beginControlFlow("case $L:", code);
      method.beginControlFlow("switch (category)");
      for (Map.Entry<String, String> entry : mapping.entrySet()) {
        String[] parts = entry.getKey().split("-");
        PluralCategory category = PluralCategory.fromString(parts[2]);
        if (category == PluralCategory.OTHER) {
          method.addStatement("case $L:\ndefault: return $S", category, entry.getValue());
        } else {
          method.addStatement("case $L: return $S", category, entry.getValue());
        }
      }
      method.endControlFlow();
      method.endControlFlow();
    }
    
    method.addStatement("default: return $S", "");
    method.endControlFlow();
    
    type.addMethod(method.build());
    
    method = MethodSpec.methodBuilder("getCurrencyDigits")
        .addModifiers(PUBLIC)
        .addParameter(Types.CLDR_CURRENCY_ENUM, "code")
        .returns(int.class);
    method.addStatement("return _CurrencyUtil.getCurrencyDigits(code)");
    type.addMethod(method.build());
  }
654207
@Override
    public RoundedMoney scaleByPowerOfTen(int power) {
        return new RoundedMoney(number.scaleByPowerOfTen(power), currency, rounding);
    }
87377
public static String toCurrency(Locale locale, double number) {
        return NumberFormat.getCurrencyInstance(locale).format(number);
    }
1194001
@Override
    public Money multiply(Number multiplicand) {
    	  NumberVerifier.checkNoInfinityOrNaN(multiplicand);
        BigDecimal multiplicandBD = MoneyUtils.getBigDecimal(multiplicand);
        if (multiplicandBD.equals(BigDecimal.ONE)) {
            return this;
        }
        BigDecimal dec = this.number.multiply(multiplicandBD);
        return new Money(dec, getCurrency());
    }
598959
@Override
    public Money scaleByPowerOfTen(int power) {
        return new Money(this.number.scaleByPowerOfTen(power), getCurrency(),
                monetaryContext);
    }
583803
public static CurrencyPair fromLunoPair(String lunoPair) {
    return new CurrencyPair(
        fromLunoCurrency(lunoPair.substring(0, 3)), fromLunoCurrency(lunoPair.substring(3)));
  }
167000
private static void money(
      CLDR.Locale locale, CLDR.Currency[] currencies, String[] numbers, CurrencyFormatOptions opts) {
    
    for (CLDR.Currency currency : currencies) {
      System.out.println("Currency " + currency);
      for (String num : numbers) {
        BigDecimal n = new BigDecimal(num);
        NumberFormatter fmt = CLDR.get().getNumberFormatter(locale);
        StringBuilder buf = new StringBuilder("  ");
        fmt.formatCurrency(n, currency, buf, opts);
        System.out.println(buf.toString());
      }
      System.out.println();
    }
    System.out.println();
  }
94604
public static BitfinexTickerSymbol ticker(final String currency, final String profitCurrency) {
    	
        final String currencyNonNull = Objects.requireNonNull(currency).toUpperCase();
        final String profitCurrencyNonNull = Objects.requireNonNull(profitCurrency).toUpperCase();
        
        return ticker(BitfinexCurrencyPair.of(currencyNonNull, profitCurrencyNonNull));
    }
232476
private TypeSpec create(NumberData data, UnitData unitData, String className) {
    LocaleID id = data.id();

    // TODO: add descriptive javadoc to type
    TypeSpec.Builder type = TypeSpec.classBuilder(className)
        .superclass(NUMBER_FORMATTER_BASE)
        .addModifiers(Modifier.PUBLIC);
    
    // Build the constructor's code block
    String fmt = "super(\n";
    List<Object> args = new ArrayList<>();

    fmt += "$T.$L,\n";
    args.add(CLDR_LOCALE_IF);
    args.add(id.safe);

    fmt += "new _Params(),\n";

    fmt += "// decimal standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.decimalFormatStandard));
    
    fmt += "// percent standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.percentFormatStandard));

    fmt += "// currency standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.currencyFormatStandard));
    
    fmt += "// currency accounting\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.currencyFormatAccounting));

    fmt += "// units standard\n";
    fmt += "patterns($S, $S)\n";
    List<NumberPattern> unitPatterns = data.decimalFormatStandard.stream()
        .map(p -> {
          p = NUMBER_PARSER.parse(p.render());
          p.format().setMaximumFractionDigits(1);
          p.format().setMinimumFractionDigits(0);
          return p;
        }).collect(Collectors.toList());
    args.addAll(getPatterns(unitPatterns));
    
    fmt += ")";

    // Build the constructor.
    MethodSpec.Builder code = MethodSpec.constructorBuilder()
        .addModifiers(PUBLIC)
        .addStatement(fmt, args.toArray());
    type.addMethod(code.build());
    
    // Create a private instance of the NumberFormatterParams type
    addParams(type, id, data);

    addCompactPattern(type, "DECIMAL_SHORT", data.decimalFormatShort, false, data);
    addCompactPattern(type, "DECIMAL_LONG", data.decimalFormatLong, false, data);
    addCompactPattern(type, "CURRENCY_SHORT", data.currencyFormatShort, true, data);
    
    addUnitPattern(type, "UNITS_LONG", unitData.long_);
    addUnitPattern(type, "UNITS_NARROW", unitData.narrow);
    addUnitPattern(type, "UNITS_SHORT", unitData.short_);
    
    addCurrencyInfo(type, data);
    addUnitWrappers(type, data);
    
    return type.build();
  }
1311712
@Override
    public RoundedMoney negate() {
        return new RoundedMoney(number.negate(Optional.ofNullable(
                monetaryContext.get(MathContext.class)).orElse(MathContext.DECIMAL64)),
                currency, rounding);
    }