Commit 08d57dab629b26db1cec85880aeb3198eabe4298

Authored by zhangmeiyang
1 parent 084b73d2

```

feat(mqtt-core): 优化接收事件类型匹配逻辑

- 将ReceiveEventType枚举中的value字段重命名为code,提高语义清晰度
- 修改构造函数参数名从value改为code,保持命名一致性
- 将静态方法of重命名为fuzzyMatching,更准确地描述模糊匹配功能
- 更新matchEventType方法调用,使用新的fuzzyMatching方法
- 修改内部实现使用code字段进行主题匹配,提升代码可读性
```
mqtt-core/src/main/java/com/diligrp/mqtt/core/type/ReceiveEventType.java
@@ -6,10 +6,10 @@ public enum ReceiveEventType { @@ -6,10 +6,10 @@ public enum ReceiveEventType {
6 PRINTER_RECEIPT_SERVICE("/printSucc/"), 6 PRINTER_RECEIPT_SERVICE("/printSucc/"),
7 PRINTER_ONLINE_SERVICE("/priGoOnline/"), 7 PRINTER_ONLINE_SERVICE("/priGoOnline/"),
8 UNKNOWN_SERVICE("unknownService"); 8 UNKNOWN_SERVICE("unknownService");
9 - public final String value; 9 + public final String code;
10 10
11 - ReceiveEventType(String value) {  
12 - this.value = value; 11 + ReceiveEventType(String code) {
  12 + this.code = code;
13 } 13 }
14 14
15 /** 15 /**
@@ -20,7 +20,7 @@ public enum ReceiveEventType { @@ -20,7 +20,7 @@ public enum ReceiveEventType {
20 */ 20 */
21 public static ReceiveEventType matchEventType(String topic) { 21 public static ReceiveEventType matchEventType(String topic) {
22 return Optional.ofNullable(topic) 22 return Optional.ofNullable(topic)
23 - .map(ReceiveEventType::of) 23 + .map(ReceiveEventType::fuzzyMatching)
24 .orElse(UNKNOWN_SERVICE); 24 .orElse(UNKNOWN_SERVICE);
25 } 25 }
26 26
@@ -30,9 +30,9 @@ public enum ReceiveEventType { @@ -30,9 +30,9 @@ public enum ReceiveEventType {
30 * @param topic 主题 30 * @param topic 主题
31 * @return {@link ReceiveEventType } 31 * @return {@link ReceiveEventType }
32 */ 32 */
33 - public static ReceiveEventType of(String topic) { 33 + public static ReceiveEventType fuzzyMatching(String topic) {
34 for (ReceiveEventType eventType : ReceiveEventType.values()) { 34 for (ReceiveEventType eventType : ReceiveEventType.values()) {
35 - if (topic.startsWith(eventType.value)) { 35 + if (topic.startsWith(eventType.code)) {
36 return eventType; 36 return eventType;
37 } 37 }
38 } 38 }