Enum:-
public StatusEnum {
MISSING("00"), INVALID("01");
....
}
I'm trying to use these strings "MISSING", "INVALID" as an attribute field for JSR Validations:-
public class SomePojo{
@NotNull(message = StatusEnum.MISSING.toString()) //this is invalid ofc, but this is what i want
@Pattern(regexp="some pattern", message = StatusEnum.INVALID.toString())
private string someField;
}
I need this so that when i programmatically validate an object against this class (javax validations), i want the constraintViolation object's getMessage to give me the enum string so that I can easily interpret the error.
I know i can put the strings directly but changing the enum will need change in the attributes as well which is a pain.