Use pattern matching switch cases

This commit is contained in:
AsamK 2023-10-17 19:52:35 +02:00
parent 80c1a6d2af
commit 8d55dfb66b
27 changed files with 395 additions and 380 deletions

View file

@ -249,11 +249,11 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
}
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);
}