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 --- .../traccar/protocol/Gps103ProtocolDecoder.java | 44 ++++++++-------------- 1 file changed, 15 insertions(+), 29 deletions(-) (limited to 'src/main/java/org/traccar/protocol/Gps103ProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gps103ProtocolDecoder.java index d1c35b478..554a23915 100644 --- a/src/main/java/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -141,35 +141,21 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } else if (value.startsWith("oil")) { return Position.ALARM_FUEL_LEAK; } - switch (value) { - case "help me": - return Position.ALARM_SOS; - case "low battery": - return Position.ALARM_LOW_BATTERY; - case "stockade": - return Position.ALARM_GEOFENCE; - case "move": - return Position.ALARM_MOVEMENT; - case "speed": - return Position.ALARM_OVERSPEED; - case "door alarm": - return Position.ALARM_DOOR; - case "ac alarm": - return Position.ALARM_POWER_CUT; - case "accident alarm": - return Position.ALARM_ACCIDENT; - case "sensor alarm": - return Position.ALARM_VIBRATION; - case "bonnet alarm": - return Position.ALARM_BONNET; - case "footbrake alarm": - return Position.ALARM_FOOT_BRAKE; - case "DTC": - return Position.ALARM_FAULT; - case "tracker": - default: - return null; - } + return switch (value) { + case "help me" -> Position.ALARM_SOS; + case "low battery" -> Position.ALARM_LOW_BATTERY; + case "stockade" -> Position.ALARM_GEOFENCE; + case "move" -> Position.ALARM_MOVEMENT; + case "speed" -> Position.ALARM_OVERSPEED; + case "door alarm" -> Position.ALARM_DOOR; + case "ac alarm" -> Position.ALARM_POWER_CUT; + case "accident alarm" -> Position.ALARM_ACCIDENT; + case "sensor alarm" -> Position.ALARM_VIBRATION; + case "bonnet alarm" -> Position.ALARM_BONNET; + case "footbrake alarm" -> Position.ALARM_FOOT_BRAKE; + case "DTC" -> Position.ALARM_FAULT; + default -> null; + }; } private Position decodeRegular(Channel channel, SocketAddress remoteAddress, String sentence) { -- cgit v1.2.3