package com.diagbot.enums;

import com.diagbot.core.KeyedNamed;
import lombok.Setter;

/**
 * @Description: 常用枚举类
 * @Author: wangyu
 * @Date: 10:25 2018/12/13
 */
public enum UsualEnum implements KeyedNamed {
    Disable(0, "不常用"),
    Enable(1, "常用");

    @Setter
    private Integer key;

    @Setter
    private String name;

    UsualEnum(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    public static UsualEnum getEnum(Integer key) {
        for (UsualEnum item : UsualEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static String getName(Integer key) {
        UsualEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}

