diff options
Diffstat (limited to 'src/main/java/org/traccar/protocol/WatchFrameDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/WatchFrameDecoder.java | 35 |
1 files changed, 9 insertions, 26 deletions
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); |