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/Mta6ProtocolDecoder.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/main/java/org/traccar/protocol/Mta6ProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Mta6ProtocolDecoder.java index 9704cf099..c76588d38 100644 --- a/src/main/java/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -75,21 +75,11 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { public float readFloat(ByteBuf buf) { switch (buf.getUnsignedByte(buf.readerIndex()) >> 6) { - case 0: - previousFloat = buf.readInt() << 2; - break; - case 1: - previousFloat = (previousFloat & 0xffffff00) + ((buf.readUnsignedByte() & 0x3f) << 2); - break; - case 2: - previousFloat = (previousFloat & 0xffff0000) + ((buf.readUnsignedShort() & 0x3fff) << 2); - break; - case 3: - previousFloat = (previousFloat & 0xff000000) + ((buf.readUnsignedMedium() & 0x3fffff) << 2); - break; - default: - LOGGER.warn("MTA6 float decoding error", new IllegalArgumentException()); - break; + case 0 -> previousFloat = buf.readInt() << 2; + case 1 -> previousFloat = (previousFloat & 0xffffff00) + ((buf.readUnsignedByte() & 0x3f) << 2); + case 2 -> previousFloat = (previousFloat & 0xffff0000) + ((buf.readUnsignedShort() & 0x3fff) << 2); + case 3 -> previousFloat = (previousFloat & 0xff000000) + ((buf.readUnsignedMedium() & 0x3fffff) << 2); + default -> LOGGER.warn("MTA6 float decoding error"); } return Float.intBitsToFloat(previousFloat); } -- cgit v1.2.3