[Java]枚举类写法

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); } }

    推荐阅读