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 --- .../traccar/protocol/NyitechProtocolDecoder.java | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java b/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java index 49bc5b824..0366cffcd 100644 --- a/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java @@ -63,18 +63,13 @@ public class NyitechProtocolDecoder extends BaseProtocolDecoder { } private String decodeAlarm(int type) { - switch (type) { - case 0x09: - return Position.ALARM_ACCELERATION; - case 0x0a: - return Position.ALARM_BRAKING; - case 0x0b: - return Position.ALARM_CORNERING; - case 0x0e: - return Position.ALARM_SOS; - default: - return null; - } + return switch (type) { + case 0x09 -> Position.ALARM_ACCELERATION; + case 0x0a -> Position.ALARM_BRAKING; + case 0x0b -> Position.ALARM_CORNERING; + case 0x0e -> Position.ALARM_SOS; + default -> null; + }; } @Override @@ -121,18 +116,10 @@ public class NyitechProtocolDecoder extends BaseProtocolDecoder { int pid = buf.readUnsignedShortLE(); int length = buf.readUnsignedByte(); switch (length) { - case 1: - position.add(ObdDecoder.decodeData(pid, buf.readByte(), true)); - break; - case 2: - position.add(ObdDecoder.decodeData(pid, buf.readShortLE(), true)); - break; - case 4: - position.add(ObdDecoder.decodeData(pid, buf.readIntLE(), true)); - break; - default: - buf.skipBytes(length); - break; + case 1 -> position.add(ObdDecoder.decodeData(pid, buf.readByte(), true)); + case 2 -> position.add(ObdDecoder.decodeData(pid, buf.readShortLE(), true)); + case 4 -> position.add(ObdDecoder.decodeData(pid, buf.readIntLE(), true)); + default -> buf.skipBytes(length); } } } -- cgit v1.2.3