LEFT | RIGHT |
(no file at all) | |
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.impl.Utility; | 5 import com.ibm.icu.impl.Utility; |
6 import com.ibm.icu.number.Grouper; | 6 import com.ibm.icu.number.Grouper; |
7 import com.ibm.icu.number.IntegerWidth; | 7 import com.ibm.icu.number.IntegerWidth; |
8 import com.ibm.icu.number.Notation; | 8 import com.ibm.icu.number.Notation; |
9 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; | 9 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; |
10 import com.ibm.icu.number.NumberFormatter.SignDisplay; | 10 import com.ibm.icu.number.NumberFormatter.SignDisplay; |
11 import com.ibm.icu.number.NumberFormatter.UnitWidth; | 11 import com.ibm.icu.number.NumberFormatter.UnitWidth; |
12 import com.ibm.icu.number.Rounder; | 12 import com.ibm.icu.number.Rounder; |
13 import com.ibm.icu.text.PluralRules; | 13 import com.ibm.icu.text.PluralRules; |
14 import com.ibm.icu.util.MeasureUnit; | 14 import com.ibm.icu.util.MeasureUnit; |
15 import com.ibm.icu.util.ULocale; | 15 import com.ibm.icu.util.ULocale; |
16 | 16 |
17 public class MacroProps implements Cloneable { | 17 public class MacroProps implements Cloneable { |
18 public Notation notation; | 18 public Notation notation; |
19 public MeasureUnit unit; | 19 public MeasureUnit unit; |
20 public Rounder rounder; | 20 public MeasureUnit perUnit; |
21 public Grouper grouper; | 21 public Rounder rounder; |
22 public Padder padder; | 22 public Grouper grouper; |
23 public IntegerWidth integerWidth; | 23 public Padder padder; |
24 public Object symbols; | 24 public IntegerWidth integerWidth; |
25 public UnitWidth unitWidth; | 25 public Object symbols; |
26 public SignDisplay sign; | 26 public UnitWidth unitWidth; |
27 public DecimalSeparatorDisplay decimal; | 27 public SignDisplay sign; |
28 public AffixPatternProvider affixProvider; // not in API; for JDK compatibilit
y mode only | 28 public DecimalSeparatorDisplay decimal; |
29 public MultiplierImpl multiplier; // not in API; for JDK compatibility mode on
ly | 29 public AffixPatternProvider affixProvider; // not in API; for JDK compatibil
ity mode only |
30 public PluralRules rules; // not in API; could be made public in the future | 30 public MultiplierImpl multiplier; // not in API; for JDK compatibility mode
only |
31 public Long threshold; // not in API; controls internal self-regulation thresh
old | 31 public PluralRules rules; // not in API; could be made public in the future |
32 public ULocale loc; | 32 public Long threshold; // not in API; controls internal self-regulation thre
shold |
| 33 public ULocale loc; |
33 | 34 |
34 /** | 35 /** |
35 * Copies values from fallback into this instance if they are null in this ins
tance. | 36 * Copies values from fallback into this instance if they are null in this i
nstance. |
36 * | 37 * |
37 * @param fallback The instance to copy from; not modified by this operation. | 38 * @param fallback |
38 */ | 39 * The instance to copy from; not modified by this operation. |
39 public void fallback(MacroProps fallback) { | 40 */ |
40 if (notation == null) notation = fallback.notation; | 41 public void fallback(MacroProps fallback) { |
41 if (unit == null) unit = fallback.unit; | 42 if (notation == null) |
42 if (rounder == null) rounder = fallback.rounder; | 43 notation = fallback.notation; |
43 if (grouper == null) grouper = fallback.grouper; | 44 if (unit == null) |
44 if (padder == null) padder = fallback.padder; | 45 unit = fallback.unit; |
45 if (integerWidth == null) integerWidth = fallback.integerWidth; | 46 if (perUnit == null) |
46 if (symbols == null) symbols = fallback.symbols; | 47 perUnit = fallback.perUnit; |
47 if (unitWidth == null) unitWidth = fallback.unitWidth; | 48 if (rounder == null) |
48 if (sign == null) sign = fallback.sign; | 49 rounder = fallback.rounder; |
49 if (decimal == null) decimal = fallback.decimal; | 50 if (grouper == null) |
50 if (affixProvider == null) affixProvider = fallback.affixProvider; | 51 grouper = fallback.grouper; |
51 if (multiplier == null) multiplier = fallback.multiplier; | 52 if (padder == null) |
52 if (rules == null) rules = fallback.rules; | 53 padder = fallback.padder; |
53 if (loc == null) loc = fallback.loc; | 54 if (integerWidth == null) |
54 } | 55 integerWidth = fallback.integerWidth; |
| 56 if (symbols == null) |
| 57 symbols = fallback.symbols; |
| 58 if (unitWidth == null) |
| 59 unitWidth = fallback.unitWidth; |
| 60 if (sign == null) |
| 61 sign = fallback.sign; |
| 62 if (decimal == null) |
| 63 decimal = fallback.decimal; |
| 64 if (affixProvider == null) |
| 65 affixProvider = fallback.affixProvider; |
| 66 if (multiplier == null) |
| 67 multiplier = fallback.multiplier; |
| 68 if (rules == null) |
| 69 rules = fallback.rules; |
| 70 if (loc == null) |
| 71 loc = fallback.loc; |
| 72 } |
55 | 73 |
56 @Override | 74 @Override |
57 public int hashCode() { | 75 public int hashCode() { |
58 return Utility.hash( | 76 return Utility.hash(notation, |
59 notation, | 77 unit, |
60 unit, | 78 perUnit, |
61 rounder, | 79 rounder, |
62 grouper, | 80 grouper, |
63 padder, | 81 padder, |
64 integerWidth, | 82 integerWidth, |
65 symbols, | 83 symbols, |
66 unitWidth, | 84 unitWidth, |
67 sign, | 85 sign, |
68 decimal, | 86 decimal, |
69 affixProvider, | 87 affixProvider, |
70 multiplier, | 88 multiplier, |
71 rules, | 89 rules, |
72 loc); | 90 loc); |
73 } | 91 } |
74 | 92 |
75 @Override | 93 @Override |
76 public boolean equals(Object _other) { | 94 public boolean equals(Object _other) { |
77 if (_other == null) return false; | 95 if (_other == null) |
78 if (this == _other) return true; | 96 return false; |
79 if (!(_other instanceof MacroProps)) return false; | 97 if (this == _other) |
80 MacroProps other = (MacroProps) _other; | 98 return true; |
81 return Utility.equals(notation, other.notation) | 99 if (!(_other instanceof MacroProps)) |
82 && Utility.equals(unit, other.unit) | 100 return false; |
83 && Utility.equals(rounder, other.rounder) | 101 MacroProps other = (MacroProps) _other; |
84 && Utility.equals(grouper, other.grouper) | 102 return Utility.equals(notation, other.notation) |
85 && Utility.equals(padder, other.padder) | 103 && Utility.equals(unit, other.unit) |
86 && Utility.equals(integerWidth, other.integerWidth) | 104 && Utility.equals(perUnit, other.perUnit) |
87 && Utility.equals(symbols, other.symbols) | 105 && Utility.equals(rounder, other.rounder) |
88 && Utility.equals(unitWidth, other.unitWidth) | 106 && Utility.equals(grouper, other.grouper) |
89 && Utility.equals(sign, other.sign) | 107 && Utility.equals(padder, other.padder) |
90 && Utility.equals(decimal, other.decimal) | 108 && Utility.equals(integerWidth, other.integerWidth) |
91 && Utility.equals(affixProvider, other.affixProvider) | 109 && Utility.equals(symbols, other.symbols) |
92 && Utility.equals(multiplier, other.multiplier) | 110 && Utility.equals(unitWidth, other.unitWidth) |
93 && Utility.equals(rules, other.rules) | 111 && Utility.equals(sign, other.sign) |
94 && Utility.equals(loc, other.loc); | 112 && Utility.equals(decimal, other.decimal) |
95 } | 113 && Utility.equals(affixProvider, other.affixProvider) |
| 114 && Utility.equals(multiplier, other.multiplier) |
| 115 && Utility.equals(rules, other.rules) |
| 116 && Utility.equals(loc, other.loc); |
| 117 } |
96 | 118 |
97 @Override | 119 @Override |
98 public Object clone() { | 120 public Object clone() { |
99 // TODO: Remove this method? | 121 // TODO: Remove this method? |
100 try { | 122 try { |
101 return super.clone(); | 123 return super.clone(); |
102 } catch (CloneNotSupportedException e) { | 124 } catch (CloneNotSupportedException e) { |
103 throw new AssertionError(e); | 125 throw new AssertionError(e); |
| 126 } |
104 } | 127 } |
105 } | |
106 } | 128 } |
LEFT | RIGHT |