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/HuaShengProtocolDecoder.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/HuaShengProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java index 7d634b0f2..d020b5e44 100644 --- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java @@ -72,24 +72,16 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { } private String decodeAlarm(int event) { - switch (event) { - case 4: - return Position.ALARM_FATIGUE_DRIVING; - case 6: - return Position.ALARM_SOS; - case 7: - return Position.ALARM_BRAKING; - case 8: - return Position.ALARM_ACCELERATION; - case 9: - return Position.ALARM_CORNERING; - case 10: - return Position.ALARM_ACCIDENT; - case 16: - return Position.ALARM_REMOVING; - default: - return null; - } + return switch (event) { + case 4 -> Position.ALARM_FATIGUE_DRIVING; + case 6 -> Position.ALARM_SOS; + case 7 -> Position.ALARM_BRAKING; + case 8 -> Position.ALARM_ACCELERATION; + case 9 -> Position.ALARM_CORNERING; + case 10 -> Position.ALARM_ACCIDENT; + case 16 -> Position.ALARM_REMOVING; + default -> null; + }; } @Override @@ -163,21 +155,12 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { while (buf.readableBytes() > 2) { String value = ByteBufUtil.hexDump(buf.readSlice(2)); int digit = Integer.parseInt(value.substring(0, 1), 16); - char prefix; - switch (digit >> 2) { - default: - prefix = 'P'; - break; - case 1: - prefix = 'C'; - break; - case 2: - prefix = 'B'; - break; - case 3: - prefix = 'U'; - break; - } + char prefix = switch (digit >> 2) { + default -> 'P'; + case 1 -> 'C'; + case 2 -> 'B'; + case 3 -> 'U'; + }; codes.append(prefix).append(digit % 4).append(value.substring(1)); if (buf.readableBytes() > 2) { codes.append(' '); |