Enum擴展,可以包含多個屬性

/**
* 配置信息
* */
public enum ConfigType {

PointsInvetee(5,"points.Invetee","30000","被邀請人獲得的獎勵積分",true),
PointsInveter(6,"points.Inveter","20000","邀請人獲得的獎勵積分",true),
RebateFatherPercent(7,"percent.rebate.father","0.2","多級返利-父節點獲得返利百分比",true),
RebateGrandapaPercent(8,"percent.rebate.grandapa","0.1","多級返利-祖父節點獲得返利百分比",true),
SecondAuthCodeOverdue(9,"second.authCode.overdue","10","驗證碼過期時間-單位爲分鐘",true),
UserCountIncrement(10,"count.user.increment","0","用戶數量增長記錄",false),
ProductPeriodIncrement(11,"count.product.period.increment","0","全站商品期號數量增長記錄",false),
;

public void setValue(int value) {
this.value = value;
}

public void setCode(String code) {
this.code = code;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public void setDescription(String description) {
this.description = description;
}
public void setManual(Boolean manual) {
this.manual = manual;
}




private int value;//值
private String code;//唯一編碼
private String defaultValue;//默認值
private String description;//描述
private Boolean manual;//是否可以手動設置


ConfigType(int value, String code,String defaultValue, String description, Boolean manual) {
this.value = value;
this.code = code;
this.defaultValue = defaultValue;
this.description = description;
this.manual = manual;
}


public String getCode() {
return code;
}
public int getValue() {
return this.value;
}
public String getDefaultValue() {
return defaultValue;
}


public String getDescription() {
return this.description;
}
public Boolean getManual() {
return manual;
}

}


  public  String getEnumDescript(int value){
ConfigType [] stas = ConfigType .class.getEnumConstants();
for(ConfigType sta: stas){
if(sta.getValue() == value){
return sta.getDescription();
}
}
return "其他";
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章