package com.diagbot.enums;

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

/**
 * @author wangfeng
 * @date 2018年11月21日 下午2:31:42
 */
public enum AbnormalStatusEnum implements KeyedNamed {
    NOT_HANDLED(0, "未处理"),
    HAS_HANDLED(1, "已处理");

    @Setter
    private int key;

    @Setter
    private String name;

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

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

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

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

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

