package com.diagbot.enums;

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

/**
 * @Description: 试用状态枚举类
 * @author: wangyu
 * @time: 11:06 2018/9/27
 */
public enum TrialStatusEnum implements KeyedNamed {
    NotTrial(0, "否"),
    OnTrial(1, "是");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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

