Java enum : Refactoring switch statements 'constant expression required' compile error?
<p>I have a class declaring constants for my app</p>

<pre><code>public class GroupConstants {
    ..
    public static final int INTEGER_VALUE = 1;
    public static final int LONG_VALUE = 2;
    public static final int STRING_VALUE = 3;
    ..
}
</code></pre>

<p>In the code there is a set of switch statements</p>

<pre><code>private static Object getValue(String stringValue, Parameter parameter) throws InvalidPatternException
{
    Object result=null;
    switch (parameter.getDataType())
    {
        case GroupConstants.STRING_VALUE: // String value
            result=stringValue;
        break;
        case GroupConstants.INTEGER_VALUE: // Long value
        case GroupConstants.LONG_VALUE:
        case GroupConstants.BOOLEAN_VALUE:
        case GroupConstants.DATE_VALUE:
..
}
</code></pre>

<p>I want to refactor the int constant values to be represented by an enum</p>

<pre><code>public enum DataType {

    UNKNOWN_VALUE(0,"unknown"),
    INTEGER_VALUE(1,"integer"),
    LONG_VALUE(2,"long"),
    STRING_VALUE(3,"string"),
    BOOLEAN_VALUE(4,"boolean"),
..
}
</code></pre>

<p>so my code might look like this</p>

<pre><code>@Deprecated
public static final int INTEGER_VALUE = DataType.INTEGER_VALUE.getId();
</code></pre>

<p>and overtime i can change my switch statements. When i change the static final int reference to point to the enum all my switch statements break. </p>

<pre><code>[javac] /home/assure/projects/tp/main/src/a/b/c/DDDDDManagerBean.java:1108: constant expression required
[javac]             case GroupConstants.INTEGER_VALUE:
[javac]                                ^
[javac] /home/assure/projects/tp/main/src/a/b/c/ParameterComponent.java:203: constant expression required
[javac]         case GroupConstants.INTEGER_VALUE:
[javac]                            ^
[javac] /home/assure/projects/tp/main/src/a/b/c/ParameterComponent.java:268: constant expression required
[javac]             case GroupConstants.INTEGER_VALUE:
[javac]                                ^
[javac] /home/assure/projects/tp/main/src/a/b/c/ParameterComponent.java:316: constant expression required
[javac]             case GroupConstants.INTEGER_VALUE:
[javac]                                ^
[javac] /home/assure/projects/tp/main/src/a/b/c/ParameterComponent.java:436: constant expression required
[javac]         case GroupConstants.INTEGER_VALUE:
</code></pre>

<p>I don't want to be forced to change all the switches yet, so its there a clean work around?</p>
