public interface Status {
public String getValue();
}
public enum BooleanStatus implements Status {
YES("Y"), NO("N");
private final String value;
private BooleanStatus(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
objectInstance.setShowOnWindow(BooleanStatus.NO.getValue());
In this way,set the objectInstance's showOnWindow field is "N" string.
===
存入int value 到数据库
public enum EmailStatusConstant implements Status {
Email_STATUS_NEW("0"),
Email_STATUS_APPROVED("1"),
Email_STATUS_DELETED("2");
private EmailStatusConstant(String value){
this.value = value;
}
private String value;
public String getValue() {
return value;
}
public int getIntValue() {
return Integer.parseInt(value);
}
@Override
public String toString() {
return value;
}
}
int i=ActStatusConstant.ACT_STATUS_NEW.getIntValue()
public String getValue();
}
public enum BooleanStatus implements Status {
YES("Y"), NO("N");
private final String value;
private BooleanStatus(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
objectInstance.setShowOnWindow(BooleanStatus.NO.getValue());
In this way,set the objectInstance's showOnWindow field is "N" string.
===
存入int value 到数据库
public enum EmailStatusConstant implements Status {
Email_STATUS_NEW("0"),
Email_STATUS_APPROVED("1"),
Email_STATUS_DELETED("2");
private EmailStatusConstant(String value){
this.value = value;
}
private String value;
public String getValue() {
return value;
}
public int getIntValue() {
return Integer.parseInt(value);
}
@Override
public String toString() {
return value;
}
}
int i=ActStatusConstant.ACT_STATUS_NEW.getIntValue()