package com.diagbot.enums;

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

/**
 * @Description:提示信息-是否诊断依据
 * @Author:zhaops
 * @time: 2018/11/30 11:16
 */
public enum IsReasonEnum implements KeyedNamed {

    No(0, "否"),
    Yes(1, "是");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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