mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30: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
|
@ -37,7 +37,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||
|
||||
|
@ -317,7 +316,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
.filter(Objects::nonNull)
|
||||
.map(m -> exportMultiAccountManager(connection, m, noReceiveOnStart))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
for (var t : initThreads) {
|
||||
try {
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -53,7 +52,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
final var number = entry.getValue().first();
|
||||
final var uuid = entry.getValue().second();
|
||||
return new JsonUserStatus(entry.getKey(), number, uuid == null ? null : uuid.toString(), uuid != null);
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
jsonWriter.write(jsonUserStatuses);
|
||||
} else {
|
||||
|
|
|
@ -9,8 +9,6 @@ import org.asamk.signal.output.JsonWriter;
|
|||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.output.PlainTextWriter;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +27,7 @@ public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
|||
) throws CommandException {
|
||||
final var accountNumbers = c.getAccountNumbers();
|
||||
if (outputWriter instanceof JsonWriter jsonWriter) {
|
||||
final var jsonAccounts = accountNumbers.stream().map(JsonAccount::new).collect(Collectors.toList());
|
||||
final var jsonAccounts = accountNumbers.stream().map(JsonAccount::new).toList();
|
||||
jsonWriter.write(jsonAccounts);
|
||||
} else if (outputWriter instanceof PlainTextWriter plainTextWriter) {
|
||||
for (final var number : accountNumbers) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.asamk.signal.output.OutputWriter;
|
|||
import org.asamk.signal.output.PlainTextWriter;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListContactsCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -48,7 +47,7 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
|||
contact.getName(),
|
||||
contact.isBlocked(),
|
||||
contact.getMessageExpirationTime());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
writer.write(jsonContacts);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListDevicesCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
|
|||
final var writer = (JsonWriter) outputWriter;
|
||||
final var jsonDevices = devices.stream()
|
||||
.map(d -> new JsonDevice(d.id(), d.name(), d.created(), d.lastSeen()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
writer.write(jsonDevices);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
group.permissionEditDetails().name(),
|
||||
group.permissionSendMessage().name(),
|
||||
groupInviteLink == null ? null : groupInviteLink.getUrl());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
jsonWriter.write(jsonGroups);
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
|||
: Base64.getEncoder().encodeToString(scannableSafetyNumber),
|
||||
id.trustLevel().name(),
|
||||
id.dateAdded().getTime());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
writer.write(jsonIdentities);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
||||
|
@ -160,8 +159,7 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
|||
groupMessageResults = results;
|
||||
} else {
|
||||
groupMessageResults = new SendGroupMessageResults(results.timestamp(),
|
||||
Stream.concat(groupMessageResults.results().stream(), results.results().stream())
|
||||
.collect(Collectors.toList()));
|
||||
Stream.concat(groupMessageResults.results().stream(), results.results().stream()).toList());
|
||||
}
|
||||
}
|
||||
outputResult(outputWriter, groupMessageResults, isNewGroup ? groupId : null);
|
||||
|
|
|
@ -160,7 +160,7 @@ public class DbusManagerImpl implements Manager {
|
|||
(long) device.get("Created").getValue(),
|
||||
(long) device.get("LastSeen").getValue(),
|
||||
thisDevice.equals(d.getObjectPath()));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,7 +191,7 @@ public class DbusManagerImpl implements Manager {
|
|||
@Override
|
||||
public List<Group> getGroups() {
|
||||
final var groups = signal.listGroups();
|
||||
return groups.stream().map(Signal.StructGroup::getObjectPath).map(this::getGroup).collect(Collectors.toList());
|
||||
return groups.stream().map(Signal.StructGroup::getObjectPath).map(this::getGroup).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,7 +216,7 @@ public class DbusManagerImpl implements Manager {
|
|||
final String name, final Set<RecipientIdentifier.Single> members, final File avatarFile
|
||||
) throws IOException, AttachmentInvalidException {
|
||||
final var newGroupId = signal.createGroup(emptyIfNull(name),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).collect(Collectors.toList()),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).toList(),
|
||||
avatarFile == null ? "" : avatarFile.getPath());
|
||||
return new Pair<>(GroupId.unknownVersion(newGroupId), new SendGroupMessageResults(0, List.of()));
|
||||
}
|
||||
|
@ -254,28 +254,22 @@ public class DbusManagerImpl implements Manager {
|
|||
: GroupPermission.EVERY_MEMBER.name());
|
||||
}
|
||||
if (updateGroup.getMembers() != null) {
|
||||
group.addMembers(updateGroup.getMembers()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
group.addMembers(updateGroup.getMembers().stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
}
|
||||
if (updateGroup.getRemoveMembers() != null) {
|
||||
group.removeMembers(updateGroup.getRemoveMembers()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
if (updateGroup.getAdmins() != null) {
|
||||
group.addAdmins(updateGroup.getAdmins()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
group.addAdmins(updateGroup.getAdmins().stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
}
|
||||
if (updateGroup.getRemoveAdmins() != null) {
|
||||
group.removeAdmins(updateGroup.getRemoveAdmins()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
if (updateGroup.isResetGroupLink()) {
|
||||
group.resetLink();
|
||||
|
@ -375,9 +369,7 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendMessageResults sendEndSessionMessage(final Set<RecipientIdentifier.Single> recipients) throws IOException {
|
||||
signal.sendEndSessionMessage(recipients.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
signal.sendEndSessionMessage(recipients.stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
|
@ -632,7 +624,7 @@ public class DbusManagerImpl implements Manager {
|
|||
.filter(r -> r instanceof RecipientIdentifier.Single)
|
||||
.map(RecipientIdentifier.Single.class::cast)
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
if (singleRecipients.size() > 0) {
|
||||
timestamp = recipientsHandler.apply(singleRecipients);
|
||||
}
|
||||
|
@ -644,7 +636,7 @@ public class DbusManagerImpl implements Manager {
|
|||
.filter(r -> r instanceof RecipientIdentifier.Group)
|
||||
.map(RecipientIdentifier.Group.class::cast)
|
||||
.map(RecipientIdentifier.Group::groupId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
for (final var groupId : groupRecipients) {
|
||||
timestamp = groupHandler.apply(groupId.serialize());
|
||||
}
|
||||
|
@ -826,7 +818,7 @@ public class DbusManagerImpl implements Manager {
|
|||
getValue(a, "isVoiceNote"),
|
||||
getValue(a, "isGif"),
|
||||
getValue(a, "isBorderless"));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
|
||||
|
@ -126,11 +125,11 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
|||
.stream()
|
||||
.filter(a -> a.id().isPresent())
|
||||
.map(this::getAttachmentMap)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
|
||||
}
|
||||
if (message.mentions().size() > 0) {
|
||||
var mentions = message.mentions().stream().map(this::getMentionMap).collect(Collectors.toList());
|
||||
var mentions = message.mentions().stream().map(this::getMentionMap).toList();
|
||||
extras.put("mentions", new Variant<>(mentions, "aa{sv}"));
|
||||
}
|
||||
extras.put("expiresInSeconds", new Variant<>(message.expiresInSeconds()));
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.net.URI;
|
|||
import java.nio.channels.OverlappingFileLockException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||
|
||||
|
@ -111,9 +110,6 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
|
||||
@Override
|
||||
public List<DBusPath> listAccounts() {
|
||||
return c.getAccountNumbers()
|
||||
.stream()
|
||||
.map(u -> new DBusPath(DbusConfig.getObjectPath(u)))
|
||||
.collect(Collectors.toList());
|
||||
return c.getAccountNumbers().stream().map(u -> new DBusPath(DbusConfig.getObjectPath(u))).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,9 +191,7 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachments, final String recipient) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessage(message, attachments, recipients);
|
||||
return sendMessage(message, attachments, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,9 +217,7 @@ public class DbusSignalImpl implements Signal {
|
|||
public long sendRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final String recipient
|
||||
) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendRemoteDeleteMessage(targetSentTimestamp, recipients);
|
||||
return sendRemoteDeleteMessage(targetSentTimestamp, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,9 +262,7 @@ public class DbusSignalImpl implements Signal {
|
|||
final long targetSentTimestamp,
|
||||
final String recipient
|
||||
) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, recipients);
|
||||
return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,10 +295,8 @@ public class DbusSignalImpl implements Signal {
|
|||
final String recipient, final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
||||
try {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
||||
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
||||
getSingleRecipientIdentifiers(List.of(recipient), m.getSelfNumber()).stream()
|
||||
.map(RecipientIdentifier.class::cast)
|
||||
.collect(Collectors.toSet()));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
|
@ -499,11 +491,7 @@ public class DbusSignalImpl implements Signal {
|
|||
@Override
|
||||
public List<byte[]> getGroupIds() {
|
||||
var groups = m.getGroups();
|
||||
var ids = new ArrayList<byte[]>(groups.size());
|
||||
for (var group : groups) {
|
||||
ids.add(group.groupId().serialize());
|
||||
}
|
||||
return ids;
|
||||
return groups.stream().map(g -> g.groupId().serialize()).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -595,9 +583,8 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public List<Boolean> isRegistered(List<String> numbers) {
|
||||
var results = new ArrayList<Boolean>();
|
||||
if (numbers.isEmpty()) {
|
||||
return results;
|
||||
return List.of();
|
||||
}
|
||||
|
||||
Map<String, Pair<String, UUID>> registered;
|
||||
|
@ -610,7 +597,7 @@ public class DbusSignalImpl implements Signal {
|
|||
return numbers.stream().map(number -> {
|
||||
var uuid = registered.get(number).second();
|
||||
return uuid != null;
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -682,7 +669,7 @@ public class DbusSignalImpl implements Signal {
|
|||
.map(a -> a.number().orElse(null))
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -844,7 +831,7 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
private static List<String> getRecipientStrings(final Set<RecipientAddress> members) {
|
||||
return members.stream().map(RecipientAddress::getLegacyIdentifier).collect(Collectors.toList());
|
||||
return members.stream().map(RecipientAddress::getLegacyIdentifier).toList();
|
||||
}
|
||||
|
||||
private static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.io.IOException;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class JsonRpcReader {
|
||||
|
@ -57,7 +56,7 @@ public class JsonRpcReader {
|
|||
}
|
||||
|
||||
return handleRequest(requestHandler, request);
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}).filter(Objects::nonNull).toList();
|
||||
|
||||
jsonRpcSender.sendBatchResponses(responseList);
|
||||
}
|
||||
|
@ -128,8 +127,7 @@ public class JsonRpcReader {
|
|||
null), null));
|
||||
return null;
|
||||
}
|
||||
return new JsonRpcBatchMessage(StreamSupport.stream(jsonNode.spliterator(), false)
|
||||
.collect(Collectors.toList()));
|
||||
return new JsonRpcBatchMessage(StreamSupport.stream(jsonNode.spliterator(), false).toList());
|
||||
} else if (jsonNode.isObject()) {
|
||||
if (jsonNode.has("result") || jsonNode.has("error")) {
|
||||
return parseJsonRpcResponse(jsonNode);
|
||||
|
|
|
@ -53,14 +53,14 @@ public class SendMessageResultUtils {
|
|||
.map(SendMessageResultUtils::getErrorMessageFromSendMessageResult)
|
||||
.filter(Objects::nonNull)
|
||||
.map(error -> entry.getKey().getIdentifier() + ": " + error))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static List<String> getErrorMessagesFromSendMessageResults(Collection<SendMessageResult> results) {
|
||||
return results.stream()
|
||||
.map(SendMessageResultUtils::getErrorMessageFromSendMessageResult)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static String getErrorMessageFromSendMessageResult(SendMessageResult result) {
|
||||
|
@ -110,10 +110,10 @@ public class SendMessageResultUtils {
|
|||
return mapResults.entrySet().stream().flatMap(entry -> {
|
||||
final var groupId = entry.getKey() instanceof RecipientIdentifier.Group g ? g.groupId() : null;
|
||||
return entry.getValue().stream().map(r -> JsonSendMessageResult.from(r, groupId));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public static List<JsonSendMessageResult> getJsonSendMessageResults(Collection<SendMessageResult> results) {
|
||||
return results.stream().map(JsonSendMessageResult::from).collect(Collectors.toList());
|
||||
return results.stream().map(JsonSendMessageResult::from).toList();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue