diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/DeviceRemoteConfig.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/DeviceRemoteConfig.java index 8bc1b62a70f040b5c129c40bc50565537fa83234..ffb71b8234fb134e35b088bbc0ed78b701977e7a 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/DeviceRemoteConfig.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/DeviceRemoteConfig.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import me.hekr.iotos.softgateway.common.utils.JsonUtil; @@ -20,6 +21,9 @@ import org.apache.commons.lang3.StringUtils; public class DeviceRemoteConfig implements Serializable { private static final Set SET = new ConcurrentHashSet<>(); private Map data = new HashMap<>(); + /** 自定义属性 */ + private final Map customData = new ConcurrentHashMap<>(); + /** 在线状态 */ private volatile boolean online; @@ -37,6 +41,34 @@ public class DeviceRemoteConfig implements Serializable { log.info("after parseAndAdd: {}", getAll()); } + /** + * 增加自定义属性信息 + * @param key key + * @param val val + * @return val + */ + public Object putCustom(Object key, Object val){ + return this.customData.put(key,val); + } + + /** + * 获取自定义信息 + * @param key key + * @return val + */ + public Object getCustom(Object key){ + return this.customData.get(key); + } + + /** + * 删除自定义信息 + * @param key key + * @return 删除的值 + */ + public Object removeCustom(Object key){ + return this.customData.remove(key); + } + @SuppressWarnings("unchecked") public static DeviceRemoteConfig parse(String line) { return new DeviceRemoteConfig(JsonUtil.fromJson(line, Map.class));