package com.diagbot.enums;

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

/**
 * @Description: 可见ID分类
 * @author: gaodm
 * @time: 2018/9/5 10:30
 */
public enum VisibleIdTypeEnum implements KeyedNamed {
    IS_IMG_VER(1, "图片验证码"),
    IS_ORDER(2, "订单编号");

    @Setter
    private int key;

    @Setter
    private String name;

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

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

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

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

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