枚举类如下所示:
public enum ProductEnum {
//币种
Product_Currency_CNY("productCurrencyCny","元","CNY"),
Product_Currency_USD("productCurrencyUsd","美元","USD"),
Product_Currency_HKD("productCurrencyHkd","港元","HKD"),
Product_Currency_GBP("productCurrencyGbp","英镑","GBP"),
Product_Currency_YEN("productCurrencyYen","日元","YEN"),
Product_Currency_EUR("productCurrencyEur","欧元","EUR"),
Product_Currency_AUD("productCurrencyAud","澳币","AUD")
;
private String key;
private String name;
private String value;
ProductEnum(String key, String name, String value){
this.key = key;
this.name = name;
this.value = value;
}
public static String getValue(String name) {
ProductEnum[] productEnums = values();
for (ProductEnum productEnum : productEnums) {
if ((productEnum.name).equals(name)) {
return productEnum.value();
}
}
return null;
}
private String value() {
return this.value;
}
public String getKey(){
return key;
}
public String getName(){
return name;
}
public String getValue(){
return value;
}
}
使用:
ProductEnum.getValue("元");