enum枚举类用法

[复制链接]
发表于 2024-10-12 10:15:13 | 显示全部楼层 |阅读模式
public enum SeeyonCurrencyConstant {

    CURRENCY_HKD("-8067278740146205859", "HKD"),
    CURRENCY_CNY("1559436427575380745", "CNY"),
    CURRENCY_USD("-8872147488443710761", "USD"),


    private String code;
    private String value;

    public String getCode() {return code;}
    public String getValue() {return value;}
    SeeyonCurrencyConstant(String code, String value) {
        this.code = code;
        this.value = value;
    }



    public static String getCodeByVal(String value) {
        SeeyonCurrencyConstant[] types = values();
        for (SeeyonCurrencyConstant x : types) {
            if (x.getValue().equals(value)) {
                return x.getCode();
            }
        }
        return null;
    }





}

GMT+8, 2025-4-20 17:30 , Processed in 0.072935 second(s), 35 queries Archiver|手机版|小黑屋|Attic ( 京ICP备2020048627号 )

快速回复 返回顶部 返回列表