package com.diagbot.enums.data;

import lombok.Setter;

public enum IsMedAllergyEnum implements AKeyedNamed {
    NO("1", "无"),
    YES("2", "有");

    @Setter
    private String key;

    @Setter
    private String name;

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

    public static IsMedAllergyEnum getEnum(String key) {
        for (IsMedAllergyEnum item : IsMedAllergyEnum.values()) {
            if (key.equals(item.getKey())) {
                return item;
            }
        }
        return null;
    }

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

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

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