[Java]枚举类写法

发布时间:2022-08-19 13:01

public enum RewardTypeEnum {

    FUND_ONLY(1, "佣金"),
    COIN_ONLY(2, "金币"),
    CMS_COIN(3, "佣金|金币");

    private Integer type;
    private String desc;


    private static final Map TYPE_MEP = new HashMap<>(RewardTypeEnum.values().length);

    static {
        for (RewardTypeEnum typeEnum : values()) {
            TYPE_MEP.put(typeEnum.type, typeEnum);
        }
    }


    RewardTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public static RewardTypeEnum getByType(Integer type) {
        return TYPE_MEP.get(type);
    }
}

ItVuer - 免责声明 - 关于我们 - 联系我们

本网站信息来源于互联网,如有侵权请联系:561261067@qq.com

桂ICP备16001015号