mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 19:10:38 +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
|
@ -55,24 +55,26 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
|
||||
// Output
|
||||
if (outputWriter instanceof JsonWriter jsonWriter) {
|
||||
|
||||
var jsonUserStatuses = registered.entrySet().stream().map(entry -> {
|
||||
final var number = entry.getValue().number();
|
||||
final var uuid = entry.getValue().uuid();
|
||||
return new JsonUserStatus(entry.getKey(), number, uuid == null ? null : uuid.toString(), uuid != null);
|
||||
}).toList();
|
||||
|
||||
jsonWriter.write(jsonUserStatuses);
|
||||
} else {
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
for (var entry : registered.entrySet()) {
|
||||
final var userStatus = entry.getValue();
|
||||
writer.println("{}: {}{}",
|
||||
entry.getKey(),
|
||||
userStatus.uuid() != null,
|
||||
userStatus.unrestrictedUnidentifiedAccess() ? " (unrestricted sealed sender)" : "");
|
||||
switch (outputWriter) {
|
||||
case JsonWriter writer -> {
|
||||
var jsonUserStatuses = registered.entrySet().stream().map(entry -> {
|
||||
final var number = entry.getValue().number();
|
||||
final var uuid = entry.getValue().uuid();
|
||||
return new JsonUserStatus(entry.getKey(),
|
||||
number,
|
||||
uuid == null ? null : uuid.toString(),
|
||||
uuid != null);
|
||||
}).toList();
|
||||
writer.write(jsonUserStatuses);
|
||||
}
|
||||
case PlainTextWriter writer -> {
|
||||
for (var entry : registered.entrySet()) {
|
||||
final var userStatus = entry.getValue();
|
||||
writer.println("{}: {}{}",
|
||||
entry.getKey(),
|
||||
userStatus.uuid() != null,
|
||||
userStatus.unrestrictedUnidentifiedAccess() ? " (unrestricted sealed sender)" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue