package com.diagbot.enums;

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

/**
 * @Description: 是否有效
 * @author: gaodm
 * @time: 2018/9/13 17:11
 */
public enum IsValidEnum implements KeyedNamed {
    IVALID(0, "无效"),
    NOT_VALID(1, "有效");

    @Setter
    private int key;

    @Setter
    private String name;

    IsValidEnum(int key, String name) {
        this.key = key;
        this.name = name;
    }

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

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

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

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