package com.diagbot.enums;

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

/**
 * @Description:
 * @author: zhaops
 * @time: 2018/9/18 18:59
 */
public enum TokenTypeEnum implements KeyedNamed {
    Online(1, "线上生成"),
    Manual(2, "手动生成"),
    Trial(3, "试用");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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