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 --- .../org/traccar/protocol/WatchFrameDecoder.java | 35 ++++++---------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'src/main/java/org/traccar/protocol/WatchFrameDecoder.java') diff --git a/src/main/java/org/traccar/protocol/WatchFrameDecoder.java b/src/main/java/org/traccar/protocol/WatchFrameDecoder.java index 9dfae8726..992cb02ab 100644 --- a/src/main/java/org/traccar/protocol/WatchFrameDecoder.java +++ b/src/main/java/org/traccar/protocol/WatchFrameDecoder.java @@ -32,14 +32,8 @@ public class WatchFrameDecoder extends BaseFrameDecoder { for (int i = buf.readerIndex(); i < buf.writerIndex(); i++) { byte b = buf.getByte(i); switch (b) { - case '[': - brackets += 1; - break; - case ']': - brackets -= 1; - break; - default: - break; + case '[' -> brackets += 1; + case ']' -> brackets -= 1; } if (brackets == 0 && i > buf.readerIndex()) { endIndex = i + 1; @@ -54,24 +48,13 @@ public class WatchFrameDecoder extends BaseFrameDecoder { if (b1 == '}') { byte b2 = buf.readByte(); switch (b2) { - case 0x01: - frame.writeByte('}'); - break; - case 0x02: - frame.writeByte('['); - break; - case 0x03: - frame.writeByte(']'); - break; - case 0x04: - frame.writeByte(','); - break; - case 0x05: - frame.writeByte('*'); - break; - default: - throw new IllegalArgumentException(String.format( - "unexpected byte at %d: 0x%02x", buf.readerIndex() - 1, b2)); + case 0x01 -> frame.writeByte('}'); + case 0x02 -> frame.writeByte('['); + case 0x03 -> frame.writeByte(']'); + case 0x04 -> frame.writeByte(','); + case 0x05 -> frame.writeByte('*'); + default -> throw new IllegalArgumentException( + String.format("unexpected byte at %d: 0x%02x", buf.readerIndex() - 1, b2)); } } else { frame.writeByte(b1); -- cgit v1.2.3