argos/dmp-backend/web/src/main/java/eu/eudat/types/ApiMessageCode.java

33 lines
862 B
Java
Raw Normal View History

2018-01-23 16:21:38 +01:00
package eu.eudat.types;
public enum ApiMessageCode {
2018-05-14 08:44:35 +02:00
NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400), DEFAULT_ERROR_MESSAGE(444),VALIDATION_MESSAGE(445);;
2018-01-23 16:21:38 +01:00
private Integer value;
private ApiMessageCode(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static ApiMessageCode fromInteger(Integer value) {
switch (value) {
case 0:
return NO_MESSAGE;
case 200:
return SUCCESS_MESSAGE;
case 300:
return WARN_MESSAGE;
case 400:
return ERROR_MESSAGE;
case 444:
return DEFAULT_ERROR_MESSAGE;
default:
throw new RuntimeException("Unsupported Api Message Code");
}
}
}