• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#License
4 package ohos.global.icu.number;
5 
6 import ohos.global.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  * @hide exposed on OHOS
17  */
18 public abstract class CurrencyPrecision extends Precision {
19 
CurrencyPrecision()20     /* package-private */ CurrencyPrecision() {
21     }
22 
23     /**
24      * Associates a currency with this rounding strategy.
25      *
26      * <p>
27      * <strong>Calling this method is <em>not required</em></strong>, because the currency specified in
28      * unit() or via a CurrencyAmount passed into format(Measure) is automatically applied to currency
29      * rounding strategies. However, this method enables you to override that automatic association.
30      *
31      * <p>
32      * This method also enables numbers to be formatted using currency rounding rules without explicitly
33      * using a currency format.
34      *
35      * @param currency
36      *            The currency to associate with this rounding strategy.
37      * @return A Precision for chaining or passing to the NumberFormatter rounding() setter.
38      * @throws IllegalArgumentException for null Currency
39      * @see NumberFormatter
40      */
withCurrency(Currency currency)41     public Precision withCurrency(Currency currency) {
42         if (currency != null) {
43             return constructFromCurrency(this, currency);
44         } else {
45             throw new IllegalArgumentException("Currency must not be null");
46         }
47     };
48 }