aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-07-07 07:33:16 -0700
committerAnton Tananaev <anton@traccar.org>2024-07-07 07:33:16 -0700
commitd0536ccbc1b7234784c5e48288bbac00a60ef821 (patch)
tree29ba8e1349eb9a5990f564edad7ddc7b5e24d7f7 /src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
parent864872b2df3e26c94d3a5826f4df504de3cf6c62 (diff)
downloadtrackermap-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/LeafSpyProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java52
1 files changed, 16 insertions, 36 deletions
diff --git a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
index 6affb85c5..bc70e8c81 100644
--- a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
@@ -55,56 +55,36 @@ public class LeafSpyProtocolDecoder extends BaseHttpProtocolDecoder {
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
for (String value : entry.getValue()) {
switch (entry.getKey()) {
- case "pass":
+ case "pass" -> {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
if (deviceSession == null) {
sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
return null;
}
position.setDeviceId(deviceSession.getDeviceId());
- break;
- case "Lat":
- position.setLatitude(Double.parseDouble(value));
- break;
- case "Long":
- position.setLongitude(Double.parseDouble(value));
- break;
- case "RPM":
+ }
+ case "Lat" -> position.setLatitude(Double.parseDouble(value));
+ case "Long" -> position.setLongitude(Double.parseDouble(value));
+ case "RPM" -> {
position.set(Position.KEY_RPM, Integer.parseInt(value));
position.setSpeed(convertSpeed(Double.parseDouble(value) / 63, "kmh"));
- break;
- case "Elv":
- position.setAltitude(Double.parseDouble(value));
- break;
- case "SOC":
- position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value));
- break;
- case "user":
- position.set(Position.KEY_DRIVER_UNIQUE_ID, value);
- break;
- case "ChrgMode":
- position.set(Position.KEY_CHARGE, Integer.parseInt(value) != 0);
- break;
- case "Odo":
- position.set(Position.KEY_OBD_ODOMETER, Integer.parseInt(value) * 1000);
- break;
- default:
+ }
+ case "Elv" -> position.setAltitude(Double.parseDouble(value));
+ case "SOC" -> position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value));
+ case "user" -> position.set(Position.KEY_DRIVER_UNIQUE_ID, value);
+ case "ChrgMode" -> position.set(Position.KEY_CHARGE, Integer.parseInt(value) != 0);
+ case "Odo" -> position.set(Position.KEY_OBD_ODOMETER, Integer.parseInt(value) * 1000);
+ default -> {
try {
position.set(entry.getKey(), Double.parseDouble(value));
} catch (NumberFormatException e) {
switch (value) {
- case "true":
- position.set(entry.getKey(), true);
- break;
- case "false":
- position.set(entry.getKey(), false);
- break;
- default:
- position.set(entry.getKey(), value);
- break;
+ case "true" -> position.set(entry.getKey(), true);
+ case "false" -> position.set(entry.getKey(), false);
+ default -> position.set(entry.getKey(), value);
}
}
- break;
+ }
}
}
}