How can I map a simple JSON object {\"status\" : \"successful\"}
automaticly map to my Java Enum within JAX-RS?
public enum Status {
SUCESSFUL
This might help you
@Entity
public class Process {
private State state;
public enum State {
RUNNING("running"), STOPPED("stopped"), PAUSED("paused");
private String value;
private State(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return this.value;
}
@JsonCreator
public static State create(String val) {
State[] states = State.values();
for (State state : states) {
if (state.getValue().equalsIgnoreCase(val)) {
return state;
}
}
return STOPPED;
}
}
}