【java】删除状态枚举类

/**
 * 删除状态枚举类
 *
 * @author lucky
 */
public enum IsDeleteEnum {
    
    

    /**
     * 0 正常
     */
    NORMAL("0", "正常", 0),

    /**
     * 1 删除
     */
    DELETE("1", "删除", 1),
    /**
     * NO_THING
     */
    NO_THING("NO_THING", "没有找到枚举类型", -9999);


    private String code;
    private String name;
    private Integer value;

    public String getCode() {
    
    
        return code;
    }

    public String getName() {
    
    
        return name;
    }

    public Integer getValue() {
    
    
        return value;
    }

    /**
     * 构造函数,枚举类型只能为私有
     *
     * @param code
     * @param name
     */
    IsDeleteEnum(String code, String name, Integer value) {
    
    
        this.code = code;
        this.name = name;
        this.value = value;
    }

    /**
     * 根据编码获取枚举类型
     *
     * @param code
     * @return
     */
    public static IsDeleteEnum getEnumByCode(String code) {
    
    
        if (code != null) {
    
    
            for (IsDeleteEnum e : IsDeleteEnum.values()) {
    
    
                if (code.equals(e.getCode())) {
    
    
                    return e;
                }
            }
        }
        return IsDeleteEnum.NO_THING;
    }
}

猜你喜欢

转载自blog.csdn.net/u010638673/article/details/127881378