]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/DaemonCommand.java
Use pattern matching switch cases
[signal-cli] / src / main / java / org / asamk / signal / commands / DaemonCommand.java
index 0cdf9cc9ba4ed0eec2362534ebc9e76c599fc7f7..5c1fac53499553cc0f76973ee88bfdc6704a71c6 100644 (file)
@@ -152,6 +152,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
                 !isDbusSystem
                         && socketFile == null
                         && tcpAddress == null
                 !isDbusSystem
                         && socketFile == null
                         && tcpAddress == null
+                        && httpAddress == null
                         && !(inheritedChannel instanceof ServerSocketChannel)
         )) {
             runDbusSingleAccount(m, false, receiveMode != ReceiveMode.ON_START);
                         && !(inheritedChannel instanceof ServerSocketChannel)
         )) {
             runDbusSingleAccount(m, false, receiveMode != ReceiveMode.ON_START);
@@ -233,6 +234,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
                 !isDbusSystem
                         && socketFile == null
                         && tcpAddress == null
                 !isDbusSystem
                         && socketFile == null
                         && tcpAddress == null
+                        && httpAddress == null
                         && !(inheritedChannel instanceof ServerSocketChannel)
         )) {
             runDbusMultiAccount(c, receiveMode != ReceiveMode.ON_START, false);
                         && !(inheritedChannel instanceof ServerSocketChannel)
         )) {
             runDbusMultiAccount(c, receiveMode != ReceiveMode.ON_START, false);
@@ -247,11 +249,11 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
     }
 
     private void addDefaultReceiveHandler(Manager m, OutputWriter outputWriter, final boolean isWeakListener) {
     }
 
     private void addDefaultReceiveHandler(Manager m, OutputWriter outputWriter, final boolean isWeakListener) {
-        final var handler = outputWriter instanceof JsonWriter o
-                ? new JsonReceiveMessageHandler(m, o)
-                : outputWriter instanceof PlainTextWriter o
-                        ? new ReceiveMessageHandler(m, o)
-                        : Manager.ReceiveMessageHandler.EMPTY;
+        final var handler = switch (outputWriter) {
+            case PlainTextWriter writer -> new ReceiveMessageHandler(m, writer);
+            case JsonWriter writer -> new JsonReceiveMessageHandler(m, writer);
+            case null -> Manager.ReceiveMessageHandler.EMPTY;
+        };
         m.addReceiveHandler(handler, isWeakListener);
     }
 
         m.addReceiveHandler(handler, isWeakListener);
     }