diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-06 19:47:06 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-06 19:47:06 -0700 |
commit | 2005fd55347816cf4a86b66ae97bc245f53f0bcd (patch) | |
tree | a62fce83953b89530c968ef2c95828a80ff18cae /src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java | |
parent | b8390005722dd1cdb24d762797ef3f98ebc37755 (diff) | |
download | trackermap-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/EelinkProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java b/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java index db1b365c3..f1cc43394 100644 --- a/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java @@ -67,35 +67,21 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_CAMERA_DATA = 0x1F; private String decodeAlarm(Short value) { - switch (value) { - case 0x01: - return Position.ALARM_POWER_OFF; - case 0x02: - return Position.ALARM_SOS; - case 0x03: - return Position.ALARM_LOW_BATTERY; - case 0x04: - return Position.ALARM_VIBRATION; - case 0x08: - case 0x09: - return Position.ALARM_GPS_ANTENNA_CUT; - case 0x25: - return Position.ALARM_REMOVING; - case 0x81: - return Position.ALARM_LOW_SPEED; - case 0x82: - return Position.ALARM_OVERSPEED; - case 0x83: - return Position.ALARM_GEOFENCE_ENTER; - case 0x84: - return Position.ALARM_GEOFENCE_EXIT; - case 0x85: - return Position.ALARM_ACCIDENT; - case 0x86: - return Position.ALARM_FALL_DOWN; - default: - return null; - } + return switch (value) { + case 0x01 -> Position.ALARM_POWER_OFF; + case 0x02 -> Position.ALARM_SOS; + case 0x03 -> Position.ALARM_LOW_BATTERY; + case 0x04 -> Position.ALARM_VIBRATION; + case 0x08, 0x09 -> Position.ALARM_GPS_ANTENNA_CUT; + case 0x25 -> Position.ALARM_REMOVING; + case 0x81 -> Position.ALARM_LOW_SPEED; + case 0x82 -> Position.ALARM_OVERSPEED; + case 0x83 -> Position.ALARM_GEOFENCE_ENTER; + case 0x84 -> Position.ALARM_GEOFENCE_EXIT; + case 0x85 -> Position.ALARM_ACCIDENT; + case 0x86 -> Position.ALARM_FALL_DOWN; + default -> null; + }; } private void decodeStatus(Position position, int status) { @@ -407,17 +393,9 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { int pid = buf.readUnsignedByte(); int value = buf.readInt(); switch (pid) { - case 0x89: - position.set(Position.KEY_FUEL_CONSUMPTION, value); - break; - case 0x8a: - position.set(Position.KEY_ODOMETER, value * 1000L); - break; - case 0x8b: - position.set(Position.KEY_FUEL_LEVEL, value / 10); - break; - default: - break; + case 0x89 -> position.set(Position.KEY_FUEL_CONSUMPTION, value); + case 0x8a -> position.set(Position.KEY_ODOMETER, value * 1000L); + case 0x8b -> position.set(Position.KEY_FUEL_LEVEL, value / 10); } } |