2026-06-24 f4bd1f3c89d906131495a0aca5aaf82966378510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cn.iocoder.yudao.module.iot.core.enums;
 
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
 
import java.util.Arrays;
 
/**
 * IoT 协议类型枚举
 *
 * 用于定义传输层协议类型
 *
 * @author 芋道源码
 */
@RequiredArgsConstructor
@Getter
public enum IotProtocolTypeEnum implements ArrayValuable<String> {
 
    TCP("tcp"),
    UDP("udp"),
    WEBSOCKET("websocket"),
    HTTP("http"),
    MQTT("mqtt"),
    EMQX("emqx"),
    COAP("coap"),
    MODBUS_TCP_CLIENT("modbus_tcp_client"),
    MODBUS_TCP_SERVER("modbus_tcp_server");
 
    public static final String[] ARRAYS = Arrays.stream(values()).map(IotProtocolTypeEnum::getType).toArray(String[]::new);
 
    /**
     * 类型
     */
    private final String type;
 
    @Override
    public String[] array() {
        return ARRAYS;
    }
 
    public static IotProtocolTypeEnum of(String type) {
        return ArrayUtil.firstMatch(e -> e.getType().equals(type), values());
    }
 
}