package com.diagbot.enums;

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

/**
 * @Description:认证状态枚举类
 * @author: zhaops
 * @time: 2018/9/17 20:25
 */
public enum AuthStatusEnum implements KeyedNamed {

    Unauthorized(0, "未认证"),
    Authorized(1, "已认证"),
    Authorizing(2, "认证中");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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