...
Code Block |
---|
// state is either 01draft or 02accepted if ("01draft".equals(state)) { doSomething(); } else if ("02accepted".equals(state)) { doSomethingDifferent(); } else { throw new IllegalStateException("state is neither 01draft nor 02accepted"); } |
Mes specific conventions
Java enums
For every enum field of a model we create, we should create corresponding Java enum in constants package.
For ex.
Code Block | ||
---|---|---|
| ||
public enum BatchNumberUniqueness {
GLOBALLY("01globally"), MANUFACTURER("02manufacturer");
private String stringValue;
private BatchNumberUniqueness(final String stringValue) {
this.stringValue = stringValue;
}
public String getStringValue() {
return stringValue;
}
public static final BatchNumberUniqueness parseString(final String string) {
if ("01globally".equals(string)) {
return GLOBALLY;
} else if ("02manufacturer".equals(string)) {
return MANUFACTURER;
} else {
return null;
}
}
} |