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