public enum PlatformFree{
FREE("free","卖家包邮"),
POST("post","平邮"),
EXPRESS("express","快递"),
EMS("ems","EMS"),
VIRTUAL("virtual","虚拟发货"),
TWENTY_FIVE("25","次日必达"),
TWENTY_SIX("26","预约配送");
private String code;
private String value;
private PlatformFree(String code,String value) {
this.code = code;
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
/**
* 根据code获取去value
* @param code
* @return
*/
public static String getValueByCode(String code){
for(PlatformFree platformFree:PlatformFree.values()){
if(code.equals(platformFree.getCode())){
return platformFree.getValue();
}
}
return null;
}
}
java的枚举enum根据code获取name等
最新推荐文章于 2024-08-05 02:09:14 发布