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/NoranProtocolEncoder.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/main/java/org/traccar/protocol/NoranProtocolEncoder.java') diff --git a/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java b/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java index e02a1313c..c8043224d 100644 --- a/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java @@ -49,21 +49,17 @@ public class NoranProtocolEncoder extends BaseProtocolEncoder { @Override protected Object encodeCommand(Command command) { - switch (command.getType()) { - case Command.TYPE_POSITION_SINGLE: - return encodeContent("*KW,000,000,000000#"); - case Command.TYPE_POSITION_PERIODIC: + return switch (command.getType()) { + case Command.TYPE_POSITION_SINGLE -> encodeContent("*KW,000,000,000000#"); + case Command.TYPE_POSITION_PERIODIC -> { int interval = command.getInteger(Command.KEY_FREQUENCY); - return encodeContent("*KW,000,002,000000," + interval + "#"); - case Command.TYPE_POSITION_STOP: - return encodeContent("*KW,000,002,000000,0#"); - case Command.TYPE_ENGINE_STOP: - return encodeContent("*KW,000,007,000000,0#"); - case Command.TYPE_ENGINE_RESUME: - return encodeContent("*KW,000,007,000000,1#"); - default: - return null; - } + yield encodeContent("*KW,000,002,000000," + interval + "#"); + } + case Command.TYPE_POSITION_STOP -> encodeContent("*KW,000,002,000000,0#"); + case Command.TYPE_ENGINE_STOP -> encodeContent("*KW,000,007,000000,0#"); + case Command.TYPE_ENGINE_RESUME -> encodeContent("*KW,000,007,000000,1#"); + default -> null; + }; } } -- cgit v1.2.3