java - Failed to serialize enum value by predefined value -


i have following enum:

public enum changemode {      none(1), add(2), update(3), delete(4);      // string value     public string getstringvalue() {         return name();     }      public static changemode getenumvalue(string v) {         return valueof(v);     }      public static changemode getenumvalue(int intvalue) {         (changemode x : values())             if (objects.equals(x.intvalue, intvalue))                 return x;          return null;     }      // int value     private int intvalue;      private changemode(int intvalue) {         this.intvalue = intvalue;     }      public int getintvalue() {         return this.intvalue;     } } 

notice enum values start 1-4 , not 0-3.

i'm using wildfly , jackson.

when i'm getting value 4 client json (using http post) i'm getting following error:

can not construct instance of com.ta9.enums.changemode number value (4): index value outside legal index range [0..3] @ [source: org.glassfish.jersey.message.internal.readerinterceptorexecutor$uncloseableinputstream@55a6e779; line: 770, column: 26] (through reference chain:


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -