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 {

    CONTROLTYPE_0(0, "默认值"),
    CONTROLTYPE_1(1, "下拉单选"),
    CONTROLTYPE_2(2, "下拉多选"),
    CONTROLTYPE_3(3, "纯文本"),
    CONTROLTYPE_5(5, "数字键盘带单位"),
    CONTROLTYPE_6(6, "文本框"),
    CONTROLTYPE_7(7, "数字键盘文本框"),
    CONTROLTYPE_99(99, "联合推送");

    @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;
    }
}
