package com.hwrj.cloud.admin.dao.excel.enumbo;

public enum SourceType {

    APP(1, "app订单"),
    PC(0, "PC订单");

    private Integer key;

    private String name;

    /**
     * @param key
     * @param name
     */
    SourceType(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    /**
     * @return Returns the key.
     */
    public Integer getKey() {
        return key;
    }

    /**
     * @return Returns the name.
     */
    public String getName() {
        return name;
    }


    /**
     * 根据Key得到枚举的Value
     * 普通for循环遍历，比较判断
     *
     * @param key
     * @return
     */
    public static SourceType getEnumType(Integer key) {
        SourceType[] alarmGrades = SourceType.values();
        for (int i = 0; i < alarmGrades.length; i++) {
            if (alarmGrades[i].getKey().equals(key)) {
                return alarmGrades[i];
            }
        }
        return SourceType.PC;
    }
}