mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-01 20:10: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
|
@ -42,10 +42,9 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||
try (InputStream attachment = m.retrieveAttachment(id)) {
|
||||
final var bytes = attachment.readAllBytes();
|
||||
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
||||
if (outputWriter instanceof PlainTextWriter writer) {
|
||||
writer.println(base64);
|
||||
} else if (outputWriter instanceof JsonWriter writer) {
|
||||
writer.write(new JsonAttachmentData(base64));
|
||||
switch (outputWriter) {
|
||||
case PlainTextWriter writer -> writer.println(base64);
|
||||
case JsonWriter writer -> writer.write(new JsonAttachmentData(base64));
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
throw new UserErrorException("Could not find attachment with ID: " + id, ex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue