| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.ruoyi.device.mqtt.util;
- import com.ruoyi.device.mqtt.enums.MsgTypeEnum;
- /**
- * MsgHandlerUtil 消息类型处理工具类
- * 将消息的一级类型和二级类型拼接成key
- *
- * @author lwm
- */
- public final class MsgHandlerUtil
- {
- private static final String UNDERLINE = "_";
- private MsgHandlerUtil()
- {
- }
- /**
- * 获取消息处理key
- *
- * @param msgTypeEnum 消息类型枚举
- * @return 消息处理key
- */
- public static String getDecoderKey(MsgTypeEnum msgTypeEnum)
- {
- return getDecoderKey(msgTypeEnum.getFirstType(), msgTypeEnum.getSecondType());
- }
- public static String getDecoderKey(Integer firstKey, Integer secondKey)
- {
- return Integer.toHexString(firstKey) + UNDERLINE + Integer.toHexString(secondKey);
- }
- /**
- * 获取消息处理key
- *
- * @param msgTypeEnum 消息类型枚举
- * @return 消息处理key
- */
- public static String getEncoderKey(MsgTypeEnum msgTypeEnum)
- {
- return getEncoderKey(msgTypeEnum.getFirstType(), msgTypeEnum.getSecondType());
- }
- public static String getEncoderKey(Integer firstKey, Integer secondKey)
- {
- return Integer.toHexString(firstKey) + UNDERLINE + Integer.toHexString(secondKey);
- }
- }
|