package com.diagbot.enums;

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

/**
 * @Description:检索显示类型枚举类
 * @author: zhoutg
 * @Date: 2018/10/26 10:35
 */
public enum ControlTypeEnum implements KeyedNamed {

    EMPTY_TAG(0, "空标签");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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