mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Use pattern matching switch cases
This commit is contained in:
parent
80c1a6d2af
commit
8d55dfb66b
27 changed files with 395 additions and 380 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue