From d0536ccbc1b7234784c5e48288bbac00a60ef821 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 7 Jul 2024 07:33:16 -0700 Subject: Update switch statements --- .../org/traccar/protocol/StbProtocolDecoder.java | 38 ++++++++-------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src/main/java/org/traccar/protocol/StbProtocolDecoder.java') 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) { -- cgit v1.2.3