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/Pt502ProtocolEncoder.java | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java') diff --git a/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java index 364ecae86..2530ae131 100644 --- a/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java @@ -44,20 +44,15 @@ public class Pt502ProtocolEncoder extends StringProtocolEncoder implements Strin @Override protected Object encodeCommand(Command command) { - switch (command.getType()) { - case Command.TYPE_CUSTOM: - return formatCommand(command, "%s\r\n", Command.KEY_DATA); - case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "#OPC%s,%s\r\n", Command.KEY_INDEX, Command.KEY_DATA); - case Command.TYPE_SET_TIMEZONE: - return formatCommand(command, "#TMZ%s\r\n", Command.KEY_TIMEZONE); - case Command.TYPE_ALARM_SPEED: - return formatCommand(command, "#SPD%s\r\n", Command.KEY_DATA); - case Command.TYPE_REQUEST_PHOTO: - return formatCommand(command, "#PHO\r\n"); - default: - return null; - } + return switch (command.getType()) { + case Command.TYPE_CUSTOM -> formatCommand(command, "%s\r\n", Command.KEY_DATA); + case Command.TYPE_OUTPUT_CONTROL -> + formatCommand(command, "#OPC%s,%s\r\n", Command.KEY_INDEX, Command.KEY_DATA); + case Command.TYPE_SET_TIMEZONE -> formatCommand(command, "#TMZ%s\r\n", Command.KEY_TIMEZONE); + case Command.TYPE_ALARM_SPEED -> formatCommand(command, "#SPD%s\r\n", Command.KEY_DATA); + case Command.TYPE_REQUEST_PHOTO -> formatCommand(command, "#PHO\r\n"); + default -> null; + }; } } -- cgit v1.2.3