From 48989879a85fd1c23a7882f771b655f42337eda8 Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Mon, 5 Dec 2016 20:49:33 +0000 Subject: [PATCH] ICU-12869 Don't use ordinal() to define public constants. Review URL: https://codereview.appspot.com/317990043 . X-SVN-Rev: 39525 --- .../core/src/com/ibm/icu/impl/CurrencyData.java | 11 ++++++++++- .../src/com/ibm/icu/text/DecimalFormatSymbols.java | 9 +++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/CurrencyData.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/CurrencyData.java index e39645ac49..09fbdd9e52 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/CurrencyData.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/CurrencyData.java @@ -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() {} diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java index c74c3f3b5d..0e3ec41ebe 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java @@ -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;