package com.diagbot.enums.data;

import lombok.Setter;

public enum BloodTypeEnum implements AKeyedNamed{

    A("1", "A"),
    B("2", "B"),
    O("3", "O"),
    AB("4", "AB"),
    UN_KNOWN("5", "不详"),
    NO_CHECK("6", "未查");

    @Setter
    private String key;

    @Setter
    private String name;

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

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

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

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

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