package com.diagbot.enums;

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

/**
 * 
 * @Description: 接入方式枚举
 * @author wangfeng
 * @date 2018年9月27日 下午4:21:29
 */
public enum AccessTypeEnum implements KeyedNamed {
    Online(1,"线上模式"),
    Embedded(3, "嵌入式"),
    InterfaceType(2, "接口方式");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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

