首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Enum良好的自小弟我描述性便于封装业务状态

2012-09-21 
Enum良好的自我描述性便于封装业务状态代码:public enum RequestFromType {errorType(0,errorType), ord

Enum良好的自我描述性便于封装业务状态
代码:


public enum RequestFromType {
errorType(0,"errorType"), orderCustomerRefund(1,"orderCustomerRefund"),orderServiceRefund(1,"orderServiceRefund"),afterRefund(3,"afterRefund");

private int code;

private String comments;


RequestFromType(int code,String comments){
this.code=code;
this.comments=comments;
}
public static RequestFromType valueOf(int code){
for(RequestFromType requestFromType : values()){
if(requestFromType.code==code){
return requestFromType;
}
}
return errorType;
}

public static RequestFromType valueOfComments(String comments){
for(RequestFromType requestFromType : values()){
if(requestFromType.comments.equalsIgnoreCase(comments)){
return requestFromType;
}
}
return errorType;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}

}

热点排行