package com.diagbot.enums.data;

import lombok.Setter;

public enum ReturnToTypeEnum implements AKeyedNamed{
    CURE("1", "治愈"),
    BETTER("2", "好转"),
    NO_CURE("3", "未愈"),
    DEATH("4", "死亡"),
    OTHER("9", "其他");

    @Setter
    private String key;

    @Setter
    private String name;

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

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

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

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

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