package com.diagbot.enums;

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

/**
 * @Description:
 * @author: zhaops
 * @time: 2018/9/19 10:05
 */
public enum StatusEnum implements KeyedNamed {
    Disable(0, "禁用"),
    Enable(1, "启用");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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

