diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
commit | d0536ccbc1b7234784c5e48288bbac00a60ef821 (patch) | |
tree | 29ba8e1349eb9a5990f564edad7ddc7b5e24d7f7 /src/main/java/org/traccar/protocol/StbProtocolDecoder.java | |
parent | 864872b2df3e26c94d3a5826f4df504de3cf6c62 (diff) | |
download | trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.gz trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.bz2 trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.zip |
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/protocol/StbProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/StbProtocolDecoder.java | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/src/main/java/org/traccar/protocol/StbProtocolDecoder.java b/src/main/java/org/traccar/protocol/StbProtocolDecoder.java index c52ab485f..18f529712 100644 --- a/src/main/java/org/traccar/protocol/StbProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/StbProtocolDecoder.java @@ -75,36 +75,24 @@ public class StbProtocolDecoder extends BaseProtocolDecoder { JsonObject propertyObject = property.asJsonObject(); String id = propertyObject.getString("id"); switch (id) { - case "01101001": - locationType = Integer.parseInt(propertyObject.getString("value")); - break; - case "01102001": - position.setLongitude( - Double.parseDouble(propertyObject.getString("value"))); - break; - case "01103001": - position.setLatitude( - Double.parseDouble(propertyObject.getString("value"))); - break; - case "01118001": - position.set( - Position.KEY_DEVICE_TEMP, Double.parseDouble(propertyObject.getString("value"))); - break; - case "01122001": - position.set( - "batteryControl", Integer.parseInt(propertyObject.getString("value"))); - break; - case "02301001": - position.set( - "switchCabinetCommand", Integer.parseInt(propertyObject.getString("value"))); - break; - default: + case "01101001" -> locationType = Integer.parseInt(propertyObject.getString("value")); + case "01102001" -> position.setLongitude( + Double.parseDouble(propertyObject.getString("value"))); + case "01103001" -> position.setLatitude( + Double.parseDouble(propertyObject.getString("value"))); + case "01118001" -> position.set( + Position.KEY_DEVICE_TEMP, Double.parseDouble(propertyObject.getString("value"))); + case "01122001" -> position.set( + "batteryControl", Integer.parseInt(propertyObject.getString("value"))); + case "02301001" -> position.set( + "switchCabinetCommand", Integer.parseInt(propertyObject.getString("value"))); + default -> { String key = "id" + id; if (propertyObject.containsKey("doorId")) { key += "Door" + propertyObject.getString("doorId"); } position.set(key, propertyObject.getString("value")); - break; + } } } if (locationType > 0) { |