1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2017 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html 4 package android.icu.number; 5 6 import android.icu.util.Currency; 7 8 /** 9 * A class that defines a rounding strategy parameterized by a currency to be used when formatting 10 * numbers in NumberFormatter. 11 * 12 * <p> 13 * To create a CurrencyPrecision, use one of the factory methods on Precision. 14 * 15 * @see NumberFormatter 16 */ 17 public abstract class CurrencyPrecision extends Precision { 18 CurrencyPrecision()19 /* package-private */ CurrencyPrecision() { 20 } 21 22 /** 23 * Associates a currency with this rounding strategy. 24 * 25 * <p> 26 * <strong>Calling this method is <em>not required</em></strong>, because the currency specified in 27 * unit() or via a CurrencyAmount passed into format(Measure) is automatically applied to currency 28 * rounding strategies. However, this method enables you to override that automatic association. 29 * 30 * <p> 31 * This method also enables numbers to be formatted using currency rounding rules without explicitly 32 * using a currency format. 33 * 34 * @param currency 35 * The currency to associate with this rounding strategy. 36 * @return A Precision for chaining or passing to the NumberFormatter rounding() setter. 37 * @throws IllegalArgumentException for null Currency 38 * @see NumberFormatter 39 */ withCurrency(Currency currency)40 public Precision withCurrency(Currency currency) { 41 if (currency != null) { 42 return constructFromCurrency(this, currency); 43 } else { 44 throw new IllegalArgumentException("Currency must not be null"); 45 } 46 }; 47 } 48