package com.diagbot.enums.data;

import lombok.Setter;

public enum RHEnum implements AKeyedNamed{
    NEGATIVE("1", "阴"),
    POSITIVE("2", "阳"),
    UN_KNOWN("3", "不详"),
    NO_CHECK("4", "未查");

    @Setter
    private String key;

    @Setter
    private String name;

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

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

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

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

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