mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 19:10:38 +00:00
Replace collect(Collectors.toList()) with toList()
This commit is contained in:
parent
06e93b84da
commit
62687d103f
41 changed files with 106 additions and 199 deletions
|
@ -6,7 +6,6 @@ import org.asamk.signal.manager.api.MessageEnvelope;
|
|||
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
record JsonCallMessage(
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) Offer offerMessage,
|
||||
|
@ -21,7 +20,7 @@ record JsonCallMessage(
|
|||
callMessage.answer().map(Answer::from).orElse(null),
|
||||
callMessage.busy().map(Busy::from).orElse(null),
|
||||
callMessage.hangup().map(Hangup::from).orElse(null),
|
||||
callMessage.iceUpdate().stream().map(IceUpdate::from).collect(Collectors.toList()));
|
||||
callMessage.iceUpdate().stream().map(IceUpdate::from).toList());
|
||||
}
|
||||
|
||||
record Offer(long id, String sdp, String type, String opaque) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
record JsonDataMessage(
|
||||
long timestamp,
|
||||
|
@ -36,20 +35,20 @@ record JsonDataMessage(
|
|||
final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
final var remoteDelete = dataMessage.remoteDeleteId().isPresent()
|
||||
? new JsonRemoteDelete(dataMessage.remoteDeleteId().get())
|
||||
: null;
|
||||
final var attachments = dataMessage.attachments().size() > 0 ? dataMessage.attachments()
|
||||
.stream()
|
||||
.map(JsonAttachment::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
final var sticker = dataMessage.sticker().isPresent() ? JsonSticker.from(dataMessage.sticker().get()) : null;
|
||||
|
||||
final var contacts = dataMessage.sharedContacts().size() > 0 ? dataMessage.sharedContacts()
|
||||
.stream()
|
||||
.map(JsonSharedContact::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
return new JsonDataMessage(timestamp,
|
||||
message,
|
||||
expiresInSeconds,
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.json;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
public record JsonPayment(String note, byte[] receipt) {
|
||||
|
||||
static JsonPayment from(MessageEnvelope.Data.Payment payment) {
|
||||
return new JsonPayment(payment.note(), payment.receipt());
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record JsonQuote(
|
||||
long id,
|
||||
|
@ -27,15 +25,14 @@ public record JsonQuote(
|
|||
final var authorUuid = address.uuid().map(UUID::toString).orElse(null);
|
||||
final var text = quote.text().orElse(null);
|
||||
|
||||
final var mentions = quote.mentions().size() > 0 ? quote.mentions()
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var mentions = quote.mentions().size() > 0
|
||||
? quote.mentions().stream().map(JsonMention::from).toList()
|
||||
: null;
|
||||
|
||||
final var attachments = quote.attachments().size() > 0 ? quote.attachments()
|
||||
.stream()
|
||||
.map(JsonQuotedAttachment::from)
|
||||
.collect(Collectors.toList()) : new ArrayList<JsonQuotedAttachment>();
|
||||
.toList() : List.<JsonQuotedAttachment>of();
|
||||
|
||||
return new JsonQuote(id, author, authorNumber, authorUuid, text, mentions, attachments);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record JsonSharedContact(
|
||||
JsonContactName name,
|
||||
|
@ -20,20 +19,18 @@ public record JsonSharedContact(
|
|||
final var name = JsonContactName.from(contact.name());
|
||||
final var avatar = contact.avatar().isPresent() ? JsonContactAvatar.from(contact.avatar().get()) : null;
|
||||
|
||||
final var phone = contact.phone().size() > 0 ? contact.phone()
|
||||
.stream()
|
||||
.map(JsonContactPhone::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var phone = contact.phone().size() > 0
|
||||
? contact.phone().stream().map(JsonContactPhone::from).toList()
|
||||
: null;
|
||||
|
||||
final var email = contact.email().size() > 0 ? contact.email()
|
||||
.stream()
|
||||
.map(JsonContactEmail::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var email = contact.email().size() > 0
|
||||
? contact.email().stream().map(JsonContactEmail::from).toList()
|
||||
: null;
|
||||
|
||||
final var address = contact.address().size() > 0 ? contact.address()
|
||||
.stream()
|
||||
.map(JsonContactAddress::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
|
||||
final var organization = contact.organization().orElse(null);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.asamk.signal.manager.groups.GroupId;
|
|||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
enum JsonSyncMessageType {
|
||||
CONTACTS_SYNC,
|
||||
|
@ -49,13 +48,8 @@ record JsonSyncMessage(
|
|||
.recipients()
|
||||
.stream()
|
||||
.map(RecipientAddress::getLegacyIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
blockedGroupIds = syncMessage.blocked()
|
||||
.get()
|
||||
.groupIds()
|
||||
.stream()
|
||||
.map(GroupId::toBase64)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
blockedGroupIds = syncMessage.blocked().get().groupIds().stream().map(GroupId::toBase64).toList();
|
||||
} else {
|
||||
blockedNumbers = null;
|
||||
blockedGroupIds = null;
|
||||
|
@ -64,7 +58,7 @@ record JsonSyncMessage(
|
|||
final var readMessages = syncMessage.read().size() > 0 ? syncMessage.read()
|
||||
.stream()
|
||||
.map(JsonSyncReadMessage::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
|
||||
final JsonSyncMessageType type;
|
||||
if (syncMessage.contacts().isPresent()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue