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.impl.number; | 3 package com.ibm.icu.impl.number; |
4 | 4 |
5 import com.ibm.icu.number.Grouper; | 5 import com.ibm.icu.number.Grouper; |
6 import com.ibm.icu.number.IntegerWidth; | 6 import com.ibm.icu.number.IntegerWidth; |
7 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; | 7 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; |
8 import com.ibm.icu.number.NumberFormatter.SignDisplay; | 8 import com.ibm.icu.number.NumberFormatter.SignDisplay; |
9 import com.ibm.icu.number.Rounder; | 9 import com.ibm.icu.number.Rounder; |
10 import com.ibm.icu.text.DecimalFormatSymbols; | 10 import com.ibm.icu.text.DecimalFormatSymbols; |
(...skipping 13 matching lines...) Expand all Loading... |
24 public Rounder rounding; | 24 public Rounder rounding; |
25 public Grouper grouping; | 25 public Grouper grouping; |
26 public boolean useCurrency; | 26 public boolean useCurrency; |
27 | 27 |
28 // Internal fields: | 28 // Internal fields: |
29 private final boolean immutable; | 29 private final boolean immutable; |
30 private volatile boolean exhausted; | 30 private volatile boolean exhausted; |
31 | 31 |
32 /** | 32 /** |
33 * @param immutable | 33 * @param immutable |
34 * Whether this MicroProps should behave as an immutable after co
nstruction with respect to the quantity | 34 * Whether this MicroProps should behave as an immutable after co
nstruction with respect |
35 * chain. | 35 * to the quantity chain. |
36 */ | 36 */ |
37 public MicroProps(boolean immutable) { | 37 public MicroProps(boolean immutable) { |
38 this.immutable = immutable; | 38 this.immutable = immutable; |
39 } | 39 } |
40 | 40 |
41 @Override | 41 @Override |
42 public MicroProps processQuantity(DecimalQuantity quantity) { | 42 public MicroProps processQuantity(DecimalQuantity quantity) { |
43 if (immutable) { | 43 if (immutable) { |
44 return (MicroProps) this.clone(); | 44 return (MicroProps) this.clone(); |
45 } else if (exhausted) { | 45 } else if (exhausted) { |
46 // Safety check | 46 // Safety check |
47 throw new AssertionError("Cannot re-use a mutable MicroProps in the
quantity chain"); | 47 throw new AssertionError("Cannot re-use a mutable MicroProps in the
quantity chain"); |
48 } else { | 48 } else { |
49 exhausted = true; | 49 exhausted = true; |
50 return this; | 50 return this; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 @Override | 54 @Override |
55 public Object clone() { | 55 public Object clone() { |
56 try { | 56 try { |
57 return super.clone(); | 57 return super.clone(); |
58 } catch (CloneNotSupportedException e) { | 58 } catch (CloneNotSupportedException e) { |
59 throw new AssertionError(e); | 59 throw new AssertionError(e); |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
OLD | NEW |