import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
public interface Manager extends Closeable {
.filter(File::isFile)
.map(File::getName)
.filter(file -> PhoneNumberFormatter.isValidNumber(file, null))
- .collect(Collectors.toList());
+ .toList();
}
String getSelfNumber();
d.getCreated(),
d.getLastSeen(),
d.getId() == account.getDeviceId());
- }).collect(Collectors.toList());
+ }).toList();
}
@Override
@Override
public List<Group> getGroups() {
- return account.getGroupStore().getGroups().stream().map(this::toGroup).collect(Collectors.toList());
+ return account.getGroupStore().getGroups().stream().map(this::toGroup).toList();
}
private Group toGroup(final GroupInfo groupInfo) {
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
account.getRecipientStore(),
account.getRecipientStore()::resolveRecipientAddress))
- .collect(Collectors.toList()));
+ .toList());
}
}
return new SendMessageResults(timestamp, results);
.map(r -> SendMessageResult.from(r,
account.getRecipientStore(),
account.getRecipientStore()::resolveRecipientAddress))
- .collect(Collectors.toList()));
+ .toList());
}
}
return new SendMessageResults(timestamp, results);
.getContacts()
.stream()
.map(p -> new Pair<>(account.getRecipientStore().resolveRecipientAddress(p.first()), p.second()))
- .collect(Collectors.toList());
+ .toList();
}
@Override
@Override
public List<Identity> getIdentities() {
- return account.getIdentityKeyStore()
- .getIdentities()
- .stream()
- .map(this::toIdentity)
- .collect(Collectors.toList());
+ return account.getIdentityKeyStore().getIdentities().stream().map(this::toIdentity).toList();
}
private Identity toIdentity(final IdentityInfo identityInfo) {
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
public class MultiAccountManagerImpl implements MultiAccountManager {
@Override
public List<String> getAccountNumbers() {
synchronized (managers) {
- return managers.stream().map(Manager::getSelfNumber).collect(Collectors.toList());
+ return managers.stream().map(Manager::getSelfNumber).toList();
}
}
.transform(p -> p.getPaymentNotification().isPresent() ? Payment.from(p) : null)
.orNull()),
dataMessage.getAttachments()
- .transform(a -> a.stream()
- .map(as -> Attachment.from(as, fileProvider))
- .collect(Collectors.toList()))
+ .transform(a -> a.stream().map(as -> Attachment.from(as, fileProvider)).toList())
.or(List.of()),
Optional.ofNullable(dataMessage.getRemoteDelete()
.transform(SignalServiceDataMessage.RemoteDelete::getTargetSentTimestamp)
dataMessage.getSharedContacts()
.transform(a -> a.stream()
.map(sharedContact -> SharedContact.from(sharedContact, fileProvider))
- .collect(Collectors.toList()))
+ .toList())
.or(List.of()),
dataMessage.getMentions()
.transform(a -> a.stream()
.map(m -> Mention.from(m, recipientResolver, addressResolver))
- .collect(Collectors.toList()))
+ .toList())
.or(List.of()),
dataMessage.getPreviews()
- .transform(a -> a.stream()
- .map(preview -> Preview.from(preview, fileProvider))
- .collect(Collectors.toList()))
+ .transform(a -> a.stream().map(preview -> Preview.from(preview, fileProvider)).toList())
.or(List.of()));
}
: quote.getMentions()
.stream()
.map(m -> Mention.from(m, recipientResolver, addressResolver))
- .collect(Collectors.toList()),
+ .toList(),
quote.getAttachments() == null
? List.of()
- : quote.getAttachments()
- .stream()
- .map(a -> Attachment.from(a, fileProvider))
- .collect(Collectors.toList()));
+ : quote.getAttachments().stream().map(a -> Attachment.from(a, fileProvider)).toList());
}
}
public record Payment(String note, byte[] receipt) {
+
static Payment from(SignalServiceDataMessage.Payment payment) {
- return new Payment(payment.getPaymentNotification().get().getNote(), payment.getPaymentNotification().get().getReceipt());
+ return new Payment(payment.getPaymentNotification().get().getNote(),
+ payment.getPaymentNotification().get().getReceipt());
}
}
Optional.ofNullable(sharedContact.getAvatar()
.transform(avatar1 -> Avatar.from(avatar1, fileProvider))
.orNull()),
- sharedContact.getPhone()
- .transform(p -> p.stream().map(Phone::from).collect(Collectors.toList()))
- .or(List.of()),
- sharedContact.getEmail()
- .transform(p -> p.stream().map(Email::from).collect(Collectors.toList()))
- .or(List.of()),
- sharedContact.getAddress()
- .transform(p -> p.stream().map(Address::from).collect(Collectors.toList()))
- .or(List.of()),
+ sharedContact.getPhone().transform(p -> p.stream().map(Phone::from).toList()).or(List.of()),
+ sharedContact.getEmail().transform(p -> p.stream().map(Email::from).toList()).or(List.of()),
+ sharedContact.getAddress().transform(p -> p.stream().map(Address::from).toList()).or(List.of()),
Optional.ofNullable(sharedContact.getOrganization().orNull()));
}
syncMessage.getRead()
.transform(r -> r.stream()
.map(rm -> Read.from(rm, recipientResolver, addressResolver))
- .collect(Collectors.toList()))
+ .toList())
.or(List.of()),
syncMessage.getViewed()
.transform(r -> r.stream()
.map(rm -> Viewed.from(rm, recipientResolver, addressResolver))
- .collect(Collectors.toList()))
+ .toList())
.or(List.of()),
Optional.ofNullable(syncMessage.getViewOnceOpen()
.transform(rm -> ViewOnceOpen.from(rm, recipientResolver, addressResolver))
return new Blocked(blockedListMessage.getAddresses()
.stream()
.map(d -> addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(d)))
- .collect(Collectors.toList()),
- blockedListMessage.getGroupIds()
- .stream()
- .map(GroupId::unknownVersion)
- .collect(Collectors.toList()));
+ .toList(), blockedListMessage.getGroupIds().stream().map(GroupId::unknownVersion).toList());
}
}
Optional.ofNullable(callMessage.getHangupMessage().transform(Hangup::from).orNull()),
Optional.ofNullable(callMessage.getBusyMessage().transform(Busy::from).orNull()),
callMessage.getIceUpdateMessages()
- .transform(m -> m.stream().map(IceUpdate::from).collect(Collectors.toList()))
+ .transform(m -> m.stream().map(IceUpdate::from).toList())
.or(List.of()),
Optional.ofNullable(callMessage.getOpaqueMessage().transform(Opaque::from).orNull()));
}
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
public class GroupHelper {
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.UPDATE)
.withId(g.getGroupId().serialize())
.withName(g.name)
- .withMembers(g.getMembers()
- .stream()
- .map(addressResolver::resolveSignalServiceAddress)
- .collect(Collectors.toList()));
+ .withMembers(g.getMembers().stream().map(addressResolver::resolveSignalServiceAddress).toList());
try {
final var attachment = createGroupAvatarAttachment(g.getGroupId());
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
recipientResolver,
account.getRecipientStore()::resolveRecipientAddress))
- .collect(Collectors.toList()));
+ .toList());
}
}
.map(addressResolver::resolveSignalServiceAddress)
.map(SignalServiceAddress::getAci)
.map(ACI::uuid)
- .collect(Collectors.toList());
+ .toList();
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
return commitChange(groupInfoV2,
groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci.uuid(), adminUuids));
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
public class SendHelper {
}
final var messageSender = dependencies.getMessageSender();
final var recipientIdList = new ArrayList<>(g.getMembersWithout(account.getSelfRecipientId()));
- final var addresses = recipientIdList.stream()
- .map(addressResolver::resolveSignalServiceAddress)
- .collect(Collectors.toList());
+ final var addresses = recipientIdList.stream().map(addressResolver::resolveSignalServiceAddress).toList();
return messageSender.sendTyping(addresses,
unidentifiedAccessHelper.getAccessFor(recipientIdList),
message,
// isRecipientUpdate is true if we've already sent this message to some recipients in the past, otherwise false.
final var isRecipientUpdate = false;
final var recipientIdList = new ArrayList<>(recipientIds);
- final var addresses = recipientIdList.stream()
- .map(addressResolver::resolveSignalServiceAddress)
- .collect(Collectors.toList());
+ final var addresses = recipientIdList.stream().map(addressResolver::resolveSignalServiceAddress).toList();
return messageSender.sendDataMessage(addresses,
unidentifiedAccessHelper.getAccessFor(recipientIdList),
isRecipientUpdate,
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.stream.Collectors;
public class StorageHelper {
.getStorageIds()
.stream()
.filter(id -> !id.isUnknown() && id.getType() != ManifestRecord.Identifier.Type.ACCOUNT_VALUE)
- .collect(Collectors.toList());
+ .toList();
for (final var record : getSignalStorageRecords(storageIds)) {
if (record.getType() == ManifestRecord.Identifier.Type.GROUPV2_VALUE) {
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.ArrayList;
-import java.util.stream.Collectors;
public class SyncHelper {
groupInfo.getMembers()
.stream()
.map(addressResolver::resolveSignalServiceAddress)
- .collect(Collectors.toList()),
+ .toList(),
groupHelper.createGroupAvatarAttachment(groupInfo.getGroupId()),
groupInfo.isMember(account.getSelfRecipientId()),
Optional.of(groupInfo.messageExpirationTime),
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import static org.whispersystems.signalservice.internal.util.Util.getSecretBytes;
}
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
- return recipients.stream().map(this::getAccessFor).collect(Collectors.toList());
+ return recipients.stream().map(this::getAccessFor).toList();
}
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipient) {
import java.io.IOException;
import java.util.HashSet;
-import java.util.stream.Collectors;
public class RetrieveStickerPackJob implements Job {
.map(c -> new JsonStickerPack.JsonSticker(c.getEmoji(),
String.valueOf(c.getId()),
c.getContentType()))
- .collect(Collectors.toList()));
+ .toList());
context.getStickerPackStore().storeManifest(packId, jsonManifest);
} catch (IOException e) {
logger.warn("Failed to retrieve sticker pack {}: {}",
g1.messageExpirationTime,
g1.blocked,
g1.archived,
- g1.members.stream()
- .map(m -> new Storage.GroupV1.Member(m.id(), null, null))
- .collect(Collectors.toList()));
+ g1.members.stream().map(m -> new Storage.GroupV1.Member(m.id(), null, null)).toList());
}
final var g2 = (GroupInfoV2) g;
Base64.getEncoder().encodeToString(g2.getMasterKey().serialize()),
g2.isBlocked(),
g2.isPermissionDenied());
- }).collect(Collectors.toList()));
+ }).toList());
}
- public record Storage(@JsonDeserialize(using = GroupsDeserializer.class) List<Object> groups) {
+ public record Storage(@JsonDeserialize(using = GroupsDeserializer.class) List<Record> groups) {
private record GroupV1(
String groupId,
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
public class IdentityKeyStore implements org.whispersystems.libsignal.state.IdentityKeyStore {
.map(f -> resolver.resolveRecipient(Long.parseLong(f.getName())))
.filter(Objects::nonNull)
.map(this::loadIdentityLocked)
- .collect(Collectors.toList());
+ .toList();
}
public void mergeRecipients(final RecipientId recipientId, final RecipientId toBeMergedRecipientId) {
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
public class MessageCache {
return Stream.empty();
}
return Arrays.stream(files).filter(File::isFile);
- }).map(CachedMessage::new).collect(Collectors.toList());
+ }).map(CachedMessage::new).toList();
}
public CachedMessage cacheMessage(SignalServiceEnvelope envelope, RecipientId recipientId) {
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
public class SignedPreKeyStore implements org.whispersystems.libsignal.state.SignedPreKeyStore {
return Arrays.stream(files)
.filter(f -> signedPreKeyFileNamePattern.matcher(f.getName()).matches())
.map(this::loadSignedPreKeyRecord)
- .collect(Collectors.toList());
+ .toList();
}
@Override
.collect(Collectors.toSet())
.stream()
.map(this::getIdentity)
- .collect(Collectors.toList());
+ .toList();
}
public IdentityKeyPair getIdentityKeyPair() {
toBeMerged.add(new Pair<>(pair.first(), pair.second().get()));
}
return pair.first();
- }).collect(Collectors.toList());
+ }).toList();
}
for (var pair : toBeMerged) {
recipientMergeHandler.mergeRecipients(pair.first(), pair.second());
.stream()
.filter(e -> e.getValue().getContact() != null)
.map(e -> new Pair<>(e.getKey(), e.getValue().getContact()))
- .collect(Collectors.toList());
+ .toList();
}
@Override
: base64.encodeToString(recipient.getProfileKeyCredential().serialize()),
contact,
profile);
- }).collect(Collectors.toList()), lastId);
+ }).toList(), lastId);
// Write to memory first to prevent corrupting the file in case of serialization errors
try (var inMemoryOutput = new ByteArrayOutputStream()) {
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
public class SenderKeyRecordStore implements org.whispersystems.libsignal.groups.state.SenderKeyStore {
return new Key(recipientId, Integer.parseInt(matcher.group(2)), UUID.fromString(matcher.group(3)));
})
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
private File getSenderKeyFile(Key key) {
.map(entry -> new Storage.SharedSenderKey(entry.recipientId().id(),
entry.deviceId(),
pair.getKey().asUuid().toString()));
- }).collect(Collectors.toList()));
+ }).toList());
// Write to memory first to prevent corrupting the file in case of serialization errors
try (var inMemoryOutput = new ByteArrayOutputStream()) {
@Override
public List<SessionRecord> loadExistingSessions(final List<SignalProtocolAddress> addresses) throws NoSessionException {
- final var keys = addresses.stream().map(this::getKey).collect(Collectors.toList());
+ final var keys = addresses.stream().map(this::getKey).toList();
synchronized (cachedSessions) {
- final var sessions = keys.stream()
- .map(this::loadSessionLocked)
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
+ final var sessions = keys.stream().map(this::loadSessionLocked).filter(Objects::nonNull).toList();
if (sessions.size() != addresses.size()) {
String message = "Mismatch! Asked for "
// get all sessions for recipient except main device session
.filter(key -> key.deviceId() != 1 && key.recipientId().equals(recipientId))
.map(Key::deviceId)
- .collect(Collectors.toList());
+ .toList();
}
}
return new Key(recipientId, Integer.parseInt(matcher.group(2)));
})
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
private File getSessionFile(Key key) {
.map(s -> new Storage.Sticker(Base64.getEncoder().encodeToString(s.getPackId().serialize()),
Base64.getEncoder().encodeToString(s.getPackKey()),
s.isInstalled()))
- .collect(Collectors.toList()));
+ .toList());
}
public record Storage(List<Storage.Sticker> stickers) {
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
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 {
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
-import java.util.stream.Collectors;
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 {
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.output.PlainTextWriter;
-import java.util.stream.Collectors;
-
public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
@Override
) 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) {
import org.asamk.signal.output.PlainTextWriter;
import java.util.UUID;
-import java.util.stream.Collectors;
public class ListContactsCommand implements JsonRpcLocalCommand {
contact.getName(),
contact.isBlocked(),
contact.getMessageExpirationTime());
- }).collect(Collectors.toList());
+ }).toList();
writer.write(jsonContacts);
}
import java.io.IOException;
import java.util.List;
-import java.util.stream.Collectors;
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);
}
}
group.permissionEditDetails().name(),
group.permissionSendMessage().name(),
groupInviteLink == null ? null : groupInviteLink.getUrl());
- }).collect(Collectors.toList());
+ }).toList();
jsonWriter.write(jsonGroups);
} else {
import java.util.Base64;
import java.util.List;
import java.util.UUID;
-import java.util.stream.Collectors;
public class ListIdentitiesCommand implements JsonRpcLocalCommand {
: Base64.getEncoder().encodeToString(scannableSafetyNumber),
id.trustLevel().name(),
id.dateAdded().getTime());
- }).collect(Collectors.toList());
+ }).toList();
writer.write(jsonIdentities);
}
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 {
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);
(long) device.get("Created").getValue(),
(long) device.get("LastSeen").getValue(),
thisDevice.equals(d.getObjectPath()));
- }).collect(Collectors.toList());
+ }).toList();
}
@Override
@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
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()));
}
: 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();
@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());
}
.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);
}
.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());
}
getValue(a, "isVoiceNote"),
getValue(a, "isGif"),
getValue(a, "isBorderless"));
- }).collect(Collectors.toList());
+ }).toList();
}
@SuppressWarnings("unchecked")
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
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()));
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 {
@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();
}
}
@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
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
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
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());
@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
@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;
return numbers.stream().map(number -> {
var uuid = registered.get(number).second();
return uuid != null;
- }).collect(Collectors.toList());
+ }).toList();
}
@Override
.map(a -> a.number().orElse(null))
.filter(Objects::nonNull)
.distinct()
- .collect(Collectors.toList());
+ .toList();
}
@Override
}
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(
import java.util.Base64;
import java.util.List;
-import java.util.stream.Collectors;
record JsonCallMessage(
@JsonInclude(JsonInclude.Include.NON_NULL) Offer offerMessage,
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) {
import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.List;
-import java.util.stream.Collectors;
record JsonDataMessage(
long timestamp,
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,
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());
}
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,
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);
}
import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.List;
-import java.util.stream.Collectors;
public record JsonSharedContact(
JsonContactName name,
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);
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
import java.util.List;
-import java.util.stream.Collectors;
enum JsonSyncMessageType {
CONTACTS_SYNC,
.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;
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()) {
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 {
}
return handleRequest(requestHandler, request);
- }).filter(Objects::nonNull).collect(Collectors.toList());
+ }).filter(Objects::nonNull).toList();
jsonRpcSender.sendBatchResponses(responseList);
}
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);
.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) {
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();
}
}