aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/AdmProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-07-06 19:47:06 -0700
committerAnton Tananaev <anton@traccar.org>2024-07-06 19:47:06 -0700
commit2005fd55347816cf4a86b66ae97bc245f53f0bcd (patch)
treea62fce83953b89530c968ef2c95828a80ff18cae /src/main/java/org/traccar/protocol/AdmProtocolDecoder.java
parentb8390005722dd1cdb24d762797ef3f98ebc37755 (diff)
downloadtrackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.gz
trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.bz2
trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.zip
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/protocol/AdmProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/AdmProtocolDecoder.java41
1 files changed, 11 insertions, 30 deletions
diff --git a/src/main/java/org/traccar/protocol/AdmProtocolDecoder.java b/src/main/java/org/traccar/protocol/AdmProtocolDecoder.java
index 1f940f7e2..3eab90988 100644
--- a/src/main/java/org/traccar/protocol/AdmProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AdmProtocolDecoder.java
@@ -108,38 +108,19 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
int endIndex = buf.readerIndex() + buf.readUnsignedByte();
while (buf.readerIndex() < endIndex) {
int mask = buf.readUnsignedByte();
- long value;
- switch (BitUtil.from(mask, 6)) {
- case 3:
- value = buf.readLongLE();
- break;
- case 2:
- value = buf.readUnsignedIntLE();
- break;
- case 1:
- value = buf.readUnsignedShortLE();
- break;
- default:
- value = buf.readUnsignedByte();
- break;
- }
+ long value = switch (BitUtil.from(mask, 6)) {
+ case 3 -> buf.readLongLE();
+ case 2 -> buf.readUnsignedIntLE();
+ case 1 -> buf.readUnsignedShortLE();
+ default -> buf.readUnsignedByte();
+ };
int index = BitUtil.to(mask, 6);
switch (index) {
- case 1:
- position.set(Position.PREFIX_TEMP + 1, value);
- break;
- case 2:
- position.set("humidity", value);
- break;
- case 3:
- position.set("illumination", value);
- break;
- case 4:
- position.set(Position.KEY_BATTERY, value);
- break;
- default:
- position.set("can" + index, value);
- break;
+ case 1 -> position.set(Position.PREFIX_TEMP + 1, value);
+ case 2 -> position.set("humidity", value);
+ case 3 -> position.set("illumination", value);
+ case 4 -> position.set(Position.KEY_BATTERY, value);
+ default -> position.set("can" + index, value);
}
}
}