package com.usky.iot.service.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yq
 * @date 2021/12/31 11:11
 */
public enum TopListener {


    /**
     * 全部设备对接
     */
    XFFJ("XFInfo","/511-XFFJ/+/+/control",1);




    private String name;
    private String code;
    //0发送队列，1监听队列2都是
    private Integer type;

    TopListener(String name, String code, Integer type){
        this.name = name;
        this.code = code;
        this.type = type;
    }

    public static TopListener parse(String code){
        TopListener topListener = null;
        for (TopListener t:TopListener.values()) {
            if (t.getCode().equals(code)){
                topListener = t;
                break;
            }
        }
        return topListener;
    }
    public static List<TopListener> parse(Integer type){
        List<TopListener> listeners = new ArrayList<>();
        for (TopListener t:TopListener.values()) {
            if (t.getType().equals(type)){
                listeners.add(t);
            }
        }
        return listeners;
    }
    public String getCode(){
        return code;
    }
    public String getName(){
        return name;
    }
    public Integer getType(){
        return type;
    }
}
