100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
AttributeState convenience method for JsonValue conversion
Rich Turner28c6c457ee4b
diff --git a/model/src/main/java/org/openremote/model/AttributeState.java b/model/src/main/java/org/openremote/model/AttributeState.javaindex 92c8b2728..3adb694d1 100644--- a/model/src/main/java/org/openremote/model/AttributeState.java+++ b/model/src/main/java/org/openremote/model/AttributeState.java@@ -20,6 +20,8 @@package org.openremote.model;import elemental.json.Json;+import elemental.json.JsonArray;+import elemental.json.JsonObject;import elemental.json.JsonValue;/**@@ -33,6 +35,11 @@ public class AttributeState {protected AttributeState() {}+ public AttributeState(JsonObject jsonObject) {+ attributeRef = new AttributeRef(jsonObject.get("attributeRef"));+ value = jsonObject.get("value");+ }+public AttributeState(AttributeRef attributeRef, JsonValue value) {this.attributeRef = attributeRef;this.value = value == null ? Json.createNull() : value;@@ -46,6 +53,13 @@ public class AttributeState {return value;}+ public JsonValue asJsonValue() {+ JsonObject jsonObject = Json.createObject();+ jsonObject.put("attributeRef", attributeRef != null ? attributeRef.asJsonValue() : Json.createNull());+ jsonObject.put("value", value != null ? value : Json.createNull());+ return jsonObject;+ }+@Overridepublic String toString() {return getClass().getSimpleName() + "{" +