Replace collect(Collectors.toList()) with toList()

This commit is contained in:
AsamK 2021-12-11 13:10:39 +01:00
parent 06e93b84da
commit 62687d103f
41 changed files with 106 additions and 199 deletions

View file

@ -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) {

View file

@ -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,

View file

@ -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());
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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()) {