Integrating List of constant names into the if-statement to avoid creating read/write...
authorrtrimana <rtrimana@uci.edu>
Tue, 22 Oct 2019 18:10:26 +0000 (11:10 -0700)
committerrtrimana <rtrimana@uci.edu>
Tue, 22 Oct 2019 18:10:26 +0000 (11:10 -0700)
Event/Event.groovy

index 15e3458..d7abdf4 100644 (file)
@@ -16,8 +16,6 @@ public class Event {
        private jsonData
        private int integerValue
        private double doubleValue
-       private List integerValues = ["battery", "hue", "saturation", "energy", "level", "temperature", 
-                                     "heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"]
        private boolean physical
        private def date
        
@@ -33,10 +31,10 @@ public class Event {
                this.data = data
                this.jsonData = new groovy.json.JsonSlurper().parseText(data)
                this.displayed = displayed
-               if (integerValues.contains(name)) {
+               if (["battery", "hue", "saturation", "energy", "level", "temperature", "heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"].contains(name)) {
                        int dot = value.indexOf('.')
                        if (dot != -1)
-             value = value.substring(0, dot)
+                       value = value.substring(0, dot)
                        this.integerValue = value.toInteger()
                        this.doubleValue = Double.parseDouble(value);           
                }