From 2005fd55347816cf4a86b66ae97bc245f53f0bcd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Jul 2024 19:47:06 -0700 Subject: Update switch statements --- .../org/traccar/protocol/CguardProtocolDecoder.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/main/java/org/traccar/protocol/CguardProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/CguardProtocolDecoder.java b/src/main/java/org/traccar/protocol/CguardProtocolDecoder.java index 90f8e0caf..fef90dbb5 100644 --- a/src/main/java/org/traccar/protocol/CguardProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/CguardProtocolDecoder.java @@ -94,25 +94,17 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder { String key = data[i * 2]; String value = data[i * 2 + 1]; switch (key) { - case "CSQ1": - position.set(Position.KEY_RSSI, Integer.parseInt(value)); - break; - case "NSQ1": - position.set(Position.KEY_SATELLITES, Integer.parseInt(value)); - break; - case "BAT1": + case "CSQ1" -> position.set(Position.KEY_RSSI, Integer.parseInt(value)); + case "NSQ1" -> position.set(Position.KEY_SATELLITES, Integer.parseInt(value)); + case "BAT1" -> { if (value.contains(".")) { position.set(Position.KEY_BATTERY, Double.parseDouble(value)); } else { position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value)); } - break; - case "PWR1": - position.set(Position.KEY_POWER, Double.parseDouble(value)); - break; - default: - position.set(key.toLowerCase(), value); - break; + } + case "PWR1" -> position.set(Position.KEY_POWER, Double.parseDouble(value)); + default -> position.set(key.toLowerCase(), value); } } -- cgit v1.2.3