package com.usky.ai.service.enums;

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

public enum TopListener {

    /**
     * AI算法识别
     */
    // 主动心跳上报
    BOARD_PING("boardPing", "/board_ping", 1),
    //新增媒体通道
    EDGE_APP_CONTROLLER("edgeAppController", "/edge_app_controller", 0),
    //媒体通道响应结果
    EDGE_APP_CONTROLLER_REPLY("edgeAppControllerReply", "/edge_app_controller_reply", 1);



    private final String name;
    private final String code;
    private final Integer type;

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

    public static TopListener parse(String code) {
        for (TopListener t : values()) {
            if (t.code.equals(code)) return t;
        }
        return null;
    }

    public static List<TopListener> parse(Integer type) {
        List<TopListener> list = new ArrayList<>();
        for (TopListener t : values()) {
            if (t.type.equals(type)) list.add(t);
        }
        return list;
    }

    public String getName() { return name; }
    public String getCode() { return code; }
    public Integer getType() { return type; }
}