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
Post a Comment