]> granicus.if.org Git - icu/commitdiff
ICU-12869 Don't use ordinal() to define public constants.
authorFredrik Roubert <roubert@google.com>
Mon, 5 Dec 2016 20:49:33 +0000 (20:49 +0000)
committerFredrik Roubert <roubert@google.com>
Mon, 5 Dec 2016 20:49:33 +0000 (20:49 +0000)
Review URL: https://codereview.appspot.com/317990043 .

X-SVN-Rev: 39525

icu4j/main/classes/core/src/com/ibm/icu/impl/CurrencyData.java
icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java

index e39645ac4951022e4ac8e1e18ba54ebf727f48ad..09fbdd9e521288ed00b522568d2244769f189b09 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Collections;
 import java.util.Map;
 
 import com.ibm.icu.text.CurrencyDisplayNames;
+import com.ibm.icu.text.DecimalFormatSymbols;
 import com.ibm.icu.util.ULocale;
 
 public class CurrencyData {
@@ -47,7 +48,15 @@ public class CurrencyData {
         private final String[][] symbols = new String[SpacingType.COUNT.ordinal()][SpacingPattern.COUNT.ordinal()];
 
         public static enum SpacingType { BEFORE, AFTER, COUNT };
-        public static enum SpacingPattern { CURRENCY_MATCH, SURROUNDING_MATCH, INSERT_BETWEEN, COUNT };
+        public static enum SpacingPattern {
+            CURRENCY_MATCH(DecimalFormatSymbols.CURRENCY_SPC_CURRENCY_MATCH),
+            SURROUNDING_MATCH(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH),
+            INSERT_BETWEEN(DecimalFormatSymbols.CURRENCY_SPC_INSERT),
+            COUNT;
+
+            SpacingPattern() {}
+            SpacingPattern(int value) { assert value == ordinal(); }
+        };
 
         public CurrencySpacingInfo() {}
 
index c74c3f3b5d5d84d84980506c67418c557cd40f33..0e3ec41ebe960f39c6fdbe92ca1aadbb6722bf18 100644 (file)
@@ -1014,23 +1014,20 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
      * {@icu} Indicates the currency match pattern used in {@link #getPatternForCurrencySpacing}.
      * @stable ICU 4.2
      */
-    public static final int CURRENCY_SPC_CURRENCY_MATCH =
-            CurrencySpacingInfo.SpacingPattern.CURRENCY_MATCH.ordinal();
+    public static final int CURRENCY_SPC_CURRENCY_MATCH = 0;
 
     /**
      * {@icu} Indicates the surrounding match pattern used in {@link
      * #getPatternForCurrencySpacing}.
      * @stable ICU 4.2
      */
-    public static final int CURRENCY_SPC_SURROUNDING_MATCH =
-            CurrencySpacingInfo.SpacingPattern.SURROUNDING_MATCH.ordinal();
+    public static final int CURRENCY_SPC_SURROUNDING_MATCH = 1;
 
     /**
      * {@icu} Indicates the insertion value used in {@link #getPatternForCurrencySpacing}.
      * @stable ICU 4.4
      */
-    public static final int CURRENCY_SPC_INSERT =
-            CurrencySpacingInfo.SpacingPattern.INSERT_BETWEEN.ordinal();
+    public static final int CURRENCY_SPC_INSERT = 2;
 
     private String[] currencySpcBeforeSym;
     private String[] currencySpcAfterSym;