I have the following code :
class MyClass {
    private Value value;
    public enum Value {
        INSERT_ONLY("INSERT_ONLY"), UPDATE_ONLY("UPDATE_ONLY"), UPSERT("UPSERT") ;
        private final String val ;
        private Value(final String v) {val = v ;}
        public String toString() {return val ;}     
        public String getVal() {
            return val;
        }
    } ;
    public Value getValue() {
        return value;
    }
    public void setValue(Value value) {
        this.value = value;
    }
}
public class one {
    public static void main(String[] args) {
        MyClass obj = new MyClass() ;
        obj.setValue(MyClass.Value.INSERT_ONLY) ;
        String s = obj.getValue().toString() ;
        String s1 = MyClass.Value.INSERT_ONLY.toString() ;
        switch(s) {
            case "INSERT_ONLY" : System.out.println("INSERT_ONLY") ;
                break ;
            case "s2" : System.out.println("s2") ;
                break ;
        }
    }
}
This code works. But what I want is that in switch-case I use the strings as defined in the enum Value. If I use s1 in case, it generates an error. What is the way out?
 
     
     
     
     
    