mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use .isEmpty() for checking lists and strings
This commit is contained in:
parent
9ba70c1808
commit
d51dd7ae57
17 changed files with 70 additions and 70 deletions
|
@ -39,13 +39,13 @@ public final class GroupInviteLinkUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!"/".equals(uri.getPath()) && uri.getPath().length() > 0) {
|
if (!"/".equals(uri.getPath()) && !uri.getPath().isEmpty()) {
|
||||||
throw new InvalidGroupLinkException("No path was expected in uri");
|
throw new InvalidGroupLinkException("No path was expected in uri");
|
||||||
}
|
}
|
||||||
|
|
||||||
var encoding = uri.getFragment();
|
var encoding = uri.getFragment();
|
||||||
|
|
||||||
if (encoding == null || encoding.length() == 0) {
|
if (encoding == null || encoding.isEmpty()) {
|
||||||
throw new InvalidGroupLinkException("No reference was in the uri");
|
throw new InvalidGroupLinkException("No reference was in the uri");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -594,14 +594,14 @@ public class GroupHelper {
|
||||||
if (members != null) {
|
if (members != null) {
|
||||||
final var requestingMembers = new HashSet<>(members);
|
final var requestingMembers = new HashSet<>(members);
|
||||||
requestingMembers.retainAll(group.getRequestingMembers());
|
requestingMembers.retainAll(group.getRequestingMembers());
|
||||||
if (requestingMembers.size() > 0) {
|
if (!requestingMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.approveJoinRequestMembers(group, requestingMembers);
|
var groupGroupChangePair = groupV2Helper.approveJoinRequestMembers(group, requestingMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
final var newMembers = new HashSet<>(members);
|
final var newMembers = new HashSet<>(members);
|
||||||
newMembers.removeAll(group.getMembers());
|
newMembers.removeAll(group.getMembers());
|
||||||
newMembers.removeAll(group.getRequestingMembers());
|
newMembers.removeAll(group.getRequestingMembers());
|
||||||
if (newMembers.size() > 0) {
|
if (!newMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
|
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
|
@ -617,20 +617,20 @@ public class GroupHelper {
|
||||||
existingRemoveMembers.removeAll(members);
|
existingRemoveMembers.removeAll(members);
|
||||||
}
|
}
|
||||||
existingRemoveMembers.remove(account.getSelfRecipientId());// self can be removed with sendQuitGroupMessage
|
existingRemoveMembers.remove(account.getSelfRecipientId());// self can be removed with sendQuitGroupMessage
|
||||||
if (existingRemoveMembers.size() > 0) {
|
if (!existingRemoveMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.removeMembers(group, existingRemoveMembers);
|
var groupGroupChangePair = groupV2Helper.removeMembers(group, existingRemoveMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
|
|
||||||
var pendingRemoveMembers = new HashSet<>(removeMembers);
|
var pendingRemoveMembers = new HashSet<>(removeMembers);
|
||||||
pendingRemoveMembers.retainAll(group.getPendingMembers());
|
pendingRemoveMembers.retainAll(group.getPendingMembers());
|
||||||
if (pendingRemoveMembers.size() > 0) {
|
if (!pendingRemoveMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.revokeInvitedMembers(group, pendingRemoveMembers);
|
var groupGroupChangePair = groupV2Helper.revokeInvitedMembers(group, pendingRemoveMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
var requestingRemoveMembers = new HashSet<>(removeMembers);
|
var requestingRemoveMembers = new HashSet<>(removeMembers);
|
||||||
requestingRemoveMembers.retainAll(group.getRequestingMembers());
|
requestingRemoveMembers.retainAll(group.getRequestingMembers());
|
||||||
if (requestingRemoveMembers.size() > 0) {
|
if (!requestingRemoveMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.refuseJoinRequestMembers(group, requestingRemoveMembers);
|
var groupGroupChangePair = groupV2Helper.refuseJoinRequestMembers(group, requestingRemoveMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
|
@ -640,7 +640,7 @@ public class GroupHelper {
|
||||||
final var newAdmins = new HashSet<>(admins);
|
final var newAdmins = new HashSet<>(admins);
|
||||||
newAdmins.retainAll(group.getMembers());
|
newAdmins.retainAll(group.getMembers());
|
||||||
newAdmins.removeAll(group.getAdminMembers());
|
newAdmins.removeAll(group.getAdminMembers());
|
||||||
if (newAdmins.size() > 0) {
|
if (!newAdmins.isEmpty()) {
|
||||||
for (var admin : newAdmins) {
|
for (var admin : newAdmins) {
|
||||||
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, true);
|
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, true);
|
||||||
result = sendUpdateGroupV2Message(group,
|
result = sendUpdateGroupV2Message(group,
|
||||||
|
@ -653,7 +653,7 @@ public class GroupHelper {
|
||||||
if (removeAdmins != null) {
|
if (removeAdmins != null) {
|
||||||
final var existingRemoveAdmins = new HashSet<>(removeAdmins);
|
final var existingRemoveAdmins = new HashSet<>(removeAdmins);
|
||||||
existingRemoveAdmins.retainAll(group.getAdminMembers());
|
existingRemoveAdmins.retainAll(group.getAdminMembers());
|
||||||
if (existingRemoveAdmins.size() > 0) {
|
if (!existingRemoveAdmins.isEmpty()) {
|
||||||
for (var admin : existingRemoveAdmins) {
|
for (var admin : existingRemoveAdmins) {
|
||||||
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, false);
|
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, false);
|
||||||
result = sendUpdateGroupV2Message(group,
|
result = sendUpdateGroupV2Message(group,
|
||||||
|
@ -666,7 +666,7 @@ public class GroupHelper {
|
||||||
if (banMembers != null) {
|
if (banMembers != null) {
|
||||||
final var newlyBannedMembers = new HashSet<>(banMembers);
|
final var newlyBannedMembers = new HashSet<>(banMembers);
|
||||||
newlyBannedMembers.removeAll(group.getBannedMembers());
|
newlyBannedMembers.removeAll(group.getBannedMembers());
|
||||||
if (newlyBannedMembers.size() > 0) {
|
if (!newlyBannedMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.banMembers(group, newlyBannedMembers);
|
var groupGroupChangePair = groupV2Helper.banMembers(group, newlyBannedMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
|
@ -675,7 +675,7 @@ public class GroupHelper {
|
||||||
if (unbanMembers != null) {
|
if (unbanMembers != null) {
|
||||||
var existingUnbanMembers = new HashSet<>(unbanMembers);
|
var existingUnbanMembers = new HashSet<>(unbanMembers);
|
||||||
existingUnbanMembers.retainAll(group.getBannedMembers());
|
existingUnbanMembers.retainAll(group.getBannedMembers());
|
||||||
if (existingUnbanMembers.size() > 0) {
|
if (!existingUnbanMembers.isEmpty()) {
|
||||||
var groupGroupChangePair = groupV2Helper.unbanMembers(group, existingUnbanMembers);
|
var groupGroupChangePair = groupV2Helper.unbanMembers(group, existingUnbanMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ public class GroupHelper {
|
||||||
if (currentAdmins.contains(account.getSelfRecipientId())
|
if (currentAdmins.contains(account.getSelfRecipientId())
|
||||||
&& currentAdmins.size() == 1
|
&& currentAdmins.size() == 1
|
||||||
&& groupInfoV2.getMembers().size() > 1
|
&& groupInfoV2.getMembers().size() > 1
|
||||||
&& newAdmins.size() == 0) {
|
&& newAdmins.isEmpty()) {
|
||||||
// Last admin can't leave the group, unless she's also the last member
|
// Last admin can't leave the group, unless she's also the last member
|
||||||
throw new LastGroupAdminException(groupInfoV2.getGroupId(), groupInfoV2.getTitle());
|
throw new LastGroupAdminException(groupInfoV2.getGroupId(), groupInfoV2.getTitle());
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,7 +465,7 @@ public class SendHelper {
|
||||||
: getSenderKeyCapableRecipientIds(recipientIds);
|
: getSenderKeyCapableRecipientIds(recipientIds);
|
||||||
final var allResults = new ArrayList<SendMessageResult>(recipientIds.size());
|
final var allResults = new ArrayList<SendMessageResult>(recipientIds.size());
|
||||||
|
|
||||||
if (senderKeyTargets.size() > 0) {
|
if (!senderKeyTargets.isEmpty()) {
|
||||||
final var results = sendGroupMessageInternalWithSenderKey(senderKeySender,
|
final var results = sendGroupMessageInternalWithSenderKey(senderKeySender,
|
||||||
senderKeyTargets,
|
senderKeyTargets,
|
||||||
distributionId,
|
distributionId,
|
||||||
|
@ -479,7 +479,7 @@ public class SendHelper {
|
||||||
.filter(r -> !r.isSuccess())
|
.filter(r -> !r.isSuccess())
|
||||||
.map(r -> context.getRecipientHelper().resolveRecipient(r.getAddress()))
|
.map(r -> context.getRecipientHelper().resolveRecipient(r.getAddress()))
|
||||||
.toList();
|
.toList();
|
||||||
if (failedTargets.size() > 0) {
|
if (!failedTargets.isEmpty()) {
|
||||||
senderKeyTargets = new HashSet<>(senderKeyTargets);
|
senderKeyTargets = new HashSet<>(senderKeyTargets);
|
||||||
failedTargets.forEach(senderKeyTargets::remove);
|
failedTargets.forEach(senderKeyTargets::remove);
|
||||||
}
|
}
|
||||||
|
@ -490,8 +490,8 @@ public class SendHelper {
|
||||||
legacyTargets.removeAll(senderKeyTargets);
|
legacyTargets.removeAll(senderKeyTargets);
|
||||||
final boolean onlyTargetIsSelfWithLinkedDevice = recipientIds.isEmpty() && account.isMultiDevice();
|
final boolean onlyTargetIsSelfWithLinkedDevice = recipientIds.isEmpty() && account.isMultiDevice();
|
||||||
|
|
||||||
if (legacyTargets.size() > 0 || onlyTargetIsSelfWithLinkedDevice) {
|
if (!legacyTargets.isEmpty() || onlyTargetIsSelfWithLinkedDevice) {
|
||||||
if (legacyTargets.size() > 0) {
|
if (!legacyTargets.isEmpty()) {
|
||||||
logger.debug("Need to do {} legacy sends.", legacyTargets.size());
|
logger.debug("Need to do {} legacy sends.", legacyTargets.size());
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Need to do a legacy send to send a sync message for a group of only ourselves.");
|
logger.debug("Need to do a legacy send to send a sync message for a group of only ourselves.");
|
||||||
|
@ -499,7 +499,7 @@ public class SendHelper {
|
||||||
|
|
||||||
final List<SendMessageResult> results = sendGroupMessageInternalWithLegacy(legacySender,
|
final List<SendMessageResult> results = sendGroupMessageInternalWithLegacy(legacySender,
|
||||||
legacyTargets,
|
legacyTargets,
|
||||||
isRecipientUpdate || allResults.size() > 0);
|
isRecipientUpdate || !allResults.isEmpty());
|
||||||
allResults.addAll(results);
|
allResults.addAll(results);
|
||||||
}
|
}
|
||||||
final var duration = Duration.ofMillis(System.currentTimeMillis() - startTime);
|
final var duration = Duration.ofMillis(System.currentTimeMillis() - startTime);
|
||||||
|
|
|
@ -298,7 +298,7 @@ public class StorageHelper {
|
||||||
logger.warn("Failed to read storage records, ignoring.");
|
logger.warn("Failed to read storage records, ignoring.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return records.size() > 0 ? records.get(0) : null;
|
return !records.isEmpty() ? records.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SignalStorageRecord> getSignalStorageRecords(final Collection<StorageId> storageIds) throws IOException {
|
private List<SignalStorageRecord> getSignalStorageRecords(final Collection<StorageId> storageIds) throws IOException {
|
||||||
|
|
|
@ -663,13 +663,13 @@ public class ManagerImpl implements Manager {
|
||||||
} else {
|
} else {
|
||||||
messageBuilder.withBody(message.messageText());
|
messageBuilder.withBody(message.messageText());
|
||||||
}
|
}
|
||||||
if (message.attachments().size() > 0) {
|
if (!message.attachments().isEmpty()) {
|
||||||
messageBuilder.withAttachments(context.getAttachmentHelper().uploadAttachments(message.attachments()));
|
messageBuilder.withAttachments(context.getAttachmentHelper().uploadAttachments(message.attachments()));
|
||||||
}
|
}
|
||||||
if (message.mentions().size() > 0) {
|
if (!message.mentions().isEmpty()) {
|
||||||
messageBuilder.withMentions(resolveMentions(message.mentions()));
|
messageBuilder.withMentions(resolveMentions(message.mentions()));
|
||||||
}
|
}
|
||||||
if (message.textStyles().size() > 0) {
|
if (!message.textStyles().isEmpty()) {
|
||||||
messageBuilder.withBodyRanges(message.textStyles().stream().map(TextStyle::toBodyRange).toList());
|
messageBuilder.withBodyRanges(message.textStyles().stream().map(TextStyle::toBodyRange).toList());
|
||||||
}
|
}
|
||||||
if (message.quote().isPresent()) {
|
if (message.quote().isPresent()) {
|
||||||
|
@ -715,7 +715,7 @@ public class ManagerImpl implements Manager {
|
||||||
manifestSticker.emoji(),
|
manifestSticker.emoji(),
|
||||||
AttachmentUtils.createAttachmentStream(streamDetails, Optional.empty())));
|
AttachmentUtils.createAttachmentStream(streamDetails, Optional.empty())));
|
||||||
}
|
}
|
||||||
if (message.previews().size() > 0) {
|
if (!message.previews().isEmpty()) {
|
||||||
final var previews = new ArrayList<SignalServicePreview>(message.previews().size());
|
final var previews = new ArrayList<SignalServicePreview>(message.previews().size());
|
||||||
for (final var p : message.previews()) {
|
for (final var p : message.previews()) {
|
||||||
final var image = p.image().isPresent() ? context.getAttachmentHelper()
|
final var image = p.image().isPresent() ? context.getAttachmentHelper()
|
||||||
|
@ -874,7 +874,7 @@ public class ManagerImpl implements Manager {
|
||||||
if (!account.isPrimaryDevice()) {
|
if (!account.isPrimaryDevice()) {
|
||||||
throw new NotPrimaryDeviceException();
|
throw new NotPrimaryDeviceException();
|
||||||
}
|
}
|
||||||
if (recipients.size() == 0) {
|
if (recipients.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final var recipientIds = context.getRecipientHelper().resolveRecipients(recipients);
|
final var recipientIds = context.getRecipientHelper().resolveRecipients(recipients);
|
||||||
|
@ -906,7 +906,7 @@ public class ManagerImpl implements Manager {
|
||||||
if (!account.isPrimaryDevice()) {
|
if (!account.isPrimaryDevice()) {
|
||||||
throw new NotPrimaryDeviceException();
|
throw new NotPrimaryDeviceException();
|
||||||
}
|
}
|
||||||
if (groupIds.size() == 0) {
|
if (groupIds.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean shouldRotateProfileKey = false;
|
boolean shouldRotateProfileKey = false;
|
||||||
|
@ -1083,7 +1083,7 @@ public class ManagerImpl implements Manager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
return messageHandlers.size() > 0;
|
return !messageHandlers.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1113,7 +1113,7 @@ public class ManagerImpl implements Manager {
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
receiveThread = null;
|
receiveThread = null;
|
||||||
isReceivingSynchronous = false;
|
isReceivingSynchronous = false;
|
||||||
if (messageHandlers.size() > 0) {
|
if (!messageHandlers.isEmpty()) {
|
||||||
startReceiveThreadIfRequired();
|
startReceiveThreadIfRequired();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
final var groupCallUpdate = message.groupCallUpdate().get();
|
final var groupCallUpdate = message.groupCallUpdate().get();
|
||||||
writer.indentedWriter().println("Era id: {}", groupCallUpdate.eraId());
|
writer.indentedWriter().println("Era id: {}", groupCallUpdate.eraId());
|
||||||
}
|
}
|
||||||
if (message.previews().size() > 0) {
|
if (!message.previews().isEmpty()) {
|
||||||
writer.println("Previews:");
|
writer.println("Previews:");
|
||||||
final var previews = message.previews();
|
final var previews = message.previews();
|
||||||
for (var preview : previews) {
|
for (var preview : previews) {
|
||||||
|
@ -135,7 +135,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
printPreview(writer.indentedWriter(), preview);
|
printPreview(writer.indentedWriter(), preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.sharedContacts().size() > 0) {
|
if (!message.sharedContacts().isEmpty()) {
|
||||||
writer.println("Contacts:");
|
writer.println("Contacts:");
|
||||||
for (var contact : message.sharedContacts()) {
|
for (var contact : message.sharedContacts()) {
|
||||||
writer.println("- Contact:");
|
writer.println("- Contact:");
|
||||||
|
@ -176,19 +176,19 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
final var remoteDelete = message.remoteDeleteId().get();
|
final var remoteDelete = message.remoteDeleteId().get();
|
||||||
writer.println("Remote delete message: timestamp = {}", remoteDelete);
|
writer.println("Remote delete message: timestamp = {}", remoteDelete);
|
||||||
}
|
}
|
||||||
if (message.mentions().size() > 0) {
|
if (!message.mentions().isEmpty()) {
|
||||||
writer.println("Mentions:");
|
writer.println("Mentions:");
|
||||||
for (var mention : message.mentions()) {
|
for (var mention : message.mentions()) {
|
||||||
printMention(writer, mention);
|
printMention(writer, mention);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.textStyles().size() > 0) {
|
if (!message.textStyles().isEmpty()) {
|
||||||
writer.println("Text styles:");
|
writer.println("Text styles:");
|
||||||
for (var textStyle : message.textStyles()) {
|
for (var textStyle : message.textStyles()) {
|
||||||
printTextStyle(writer, textStyle);
|
printTextStyle(writer, textStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.attachments().size() > 0) {
|
if (!message.attachments().isEmpty()) {
|
||||||
writer.println("Attachments:");
|
writer.println("Attachments:");
|
||||||
for (var attachment : message.attachments()) {
|
for (var attachment : message.attachments()) {
|
||||||
writer.println("- Attachment:");
|
writer.println("- Attachment:");
|
||||||
|
@ -283,7 +283,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
var hangupMessage = callMessage.hangup().get();
|
var hangupMessage = callMessage.hangup().get();
|
||||||
writer.println("Hangup message: {}", hangupMessage.id());
|
writer.println("Hangup message: {}", hangupMessage.id());
|
||||||
}
|
}
|
||||||
if (callMessage.iceUpdate().size() > 0) {
|
if (!callMessage.iceUpdate().isEmpty()) {
|
||||||
writer.println("Ice update messages:");
|
writer.println("Ice update messages:");
|
||||||
var iceUpdateMessages = callMessage.iceUpdate();
|
var iceUpdateMessages = callMessage.iceUpdate();
|
||||||
for (var iceUpdateMessage : iceUpdateMessages) {
|
for (var iceUpdateMessage : iceUpdateMessages) {
|
||||||
|
@ -313,7 +313,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
if (syncMessage.groups().isPresent()) {
|
if (syncMessage.groups().isPresent()) {
|
||||||
writer.println("Received sync groups.");
|
writer.println("Received sync groups.");
|
||||||
}
|
}
|
||||||
if (syncMessage.read().size() > 0) {
|
if (!syncMessage.read().isEmpty()) {
|
||||||
writer.println("Received sync read messages list");
|
writer.println("Received sync read messages list");
|
||||||
for (var rm : syncMessage.read()) {
|
for (var rm : syncMessage.read()) {
|
||||||
writer.println("- From: {} Message timestamp: {}",
|
writer.println("- From: {} Message timestamp: {}",
|
||||||
|
@ -321,7 +321,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
DateUtils.formatTimestamp(rm.timestamp()));
|
DateUtils.formatTimestamp(rm.timestamp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (syncMessage.viewed().size() > 0) {
|
if (!syncMessage.viewed().isEmpty()) {
|
||||||
writer.println("Received sync viewed messages list");
|
writer.println("Received sync viewed messages list");
|
||||||
for (var vm : syncMessage.viewed()) {
|
for (var vm : syncMessage.viewed()) {
|
||||||
writer.println("- From: {} Message timestamp: {}",
|
writer.println("- From: {} Message timestamp: {}",
|
||||||
|
@ -335,7 +335,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
String to;
|
String to;
|
||||||
if (sentTranscriptMessage.destination().isPresent()) {
|
if (sentTranscriptMessage.destination().isPresent()) {
|
||||||
to = formatContact(sentTranscriptMessage.destination().get());
|
to = formatContact(sentTranscriptMessage.destination().get());
|
||||||
} else if (sentTranscriptMessage.recipients().size() > 0) {
|
} else if (!sentTranscriptMessage.recipients().isEmpty()) {
|
||||||
to = sentTranscriptMessage.recipients()
|
to = sentTranscriptMessage.recipients()
|
||||||
.stream()
|
.stream()
|
||||||
.map(this::formatContact)
|
.map(this::formatContact)
|
||||||
|
@ -429,13 +429,13 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
if (quote.text().isPresent()) {
|
if (quote.text().isPresent()) {
|
||||||
writer.println("Text: {}", quote.text().get());
|
writer.println("Text: {}", quote.text().get());
|
||||||
}
|
}
|
||||||
if (quote.mentions() != null && quote.mentions().size() > 0) {
|
if (quote.mentions() != null && !quote.mentions().isEmpty()) {
|
||||||
writer.println("Mentions:");
|
writer.println("Mentions:");
|
||||||
for (var mention : quote.mentions()) {
|
for (var mention : quote.mentions()) {
|
||||||
printMention(writer, mention);
|
printMention(writer, mention);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quote.attachments().size() > 0) {
|
if (!quote.attachments().isEmpty()) {
|
||||||
writer.println("Attachments:");
|
writer.println("Attachments:");
|
||||||
for (var attachment : quote.attachments()) {
|
for (var attachment : quote.attachments()) {
|
||||||
writer.println("- Attachment:");
|
writer.println("- Attachment:");
|
||||||
|
@ -478,7 +478,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
writer.println("Organisation: {}", contact.organization().get());
|
writer.println("Organisation: {}", contact.organization().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact.phone().size() > 0) {
|
if (!contact.phone().isEmpty()) {
|
||||||
writer.println("Phone details:");
|
writer.println("Phone details:");
|
||||||
for (var phone : contact.phone()) {
|
for (var phone : contact.phone()) {
|
||||||
writer.println("- Phone:");
|
writer.println("- Phone:");
|
||||||
|
@ -492,7 +492,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact.email().size() > 0) {
|
if (!contact.email().isEmpty()) {
|
||||||
writer.println("Email details:");
|
writer.println("Email details:");
|
||||||
for (var email : contact.email()) {
|
for (var email : contact.email()) {
|
||||||
writer.println("- Email:");
|
writer.println("- Email:");
|
||||||
|
@ -506,7 +506,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact.address().size() > 0) {
|
if (!contact.address().isEmpty()) {
|
||||||
writer.println("Address details:");
|
writer.println("Address details:");
|
||||||
for (var address : contact.address()) {
|
for (var address : contact.address()) {
|
||||||
writer.println("- Address:");
|
writer.println("- Address:");
|
||||||
|
@ -615,7 +615,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
if (attachment.isGif()) {
|
if (attachment.isGif()) {
|
||||||
flags.add("video gif");
|
flags.add("video gif");
|
||||||
}
|
}
|
||||||
if (flags.size() > 0) {
|
if (!flags.isEmpty()) {
|
||||||
writer.println("Flags: {}", String.join(", ", flags));
|
writer.println("Flags: {}", String.join(", ", flags));
|
||||||
}
|
}
|
||||||
if (attachment.width().isPresent() || attachment.height().isPresent()) {
|
if (attachment.width().isPresent() || attachment.height().isPresent()) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
final var groupIdStrings = ns.<String>getList("group-id");
|
final var groupIdStrings = ns.<String>getList("group-id");
|
||||||
final var groupIds = CommandUtil.getGroupIds(groupIdStrings);
|
final var groupIds = CommandUtil.getGroupIds(groupIdStrings);
|
||||||
if (groupIds.size() > 0) {
|
if (!groupIds.isEmpty()) {
|
||||||
groups = groups.stream().filter(g -> groupIds.contains(g.groupId())).toList();
|
groups = groups.stream().filter(g -> groupIds.contains(g.groupId())).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class DbusCommandHandler {
|
||||||
SignalControl.class);
|
SignalControl.class);
|
||||||
try {
|
try {
|
||||||
final var accounts = control.listAccounts();
|
final var accounts = control.listAccounts();
|
||||||
if (accounts.size() == 0) {
|
if (accounts.isEmpty()) {
|
||||||
throw new UserErrorException("No local users found, you first need to register or link an account");
|
throw new UserErrorException("No local users found, you first need to register or link an account");
|
||||||
} else if (accounts.size() > 1) {
|
} else if (accounts.size() > 1) {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
public SendGroupMessageResults quitGroup(
|
public SendGroupMessageResults quitGroup(
|
||||||
final GroupId groupId, final Set<RecipientIdentifier.Single> groupAdmins
|
final GroupId groupId, final Set<RecipientIdentifier.Single> groupAdmins
|
||||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
|
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
|
||||||
if (groupAdmins.size() > 0) {
|
if (!groupAdmins.isEmpty()) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
|
final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
|
||||||
|
@ -522,7 +522,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
if (isWeakListener) {
|
if (isWeakListener) {
|
||||||
weakHandlers.add(handler);
|
weakHandlers.add(handler);
|
||||||
} else {
|
} else {
|
||||||
if (messageHandlers.size() == 0) {
|
if (messageHandlers.isEmpty()) {
|
||||||
installMessageHandlers();
|
installMessageHandlers();
|
||||||
}
|
}
|
||||||
messageHandlers.add(handler);
|
messageHandlers.add(handler);
|
||||||
|
@ -535,7 +535,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
weakHandlers.remove(handler);
|
weakHandlers.remove(handler);
|
||||||
messageHandlers.remove(handler);
|
messageHandlers.remove(handler);
|
||||||
if (messageHandlers.size() == 0) {
|
if (messageHandlers.isEmpty()) {
|
||||||
uninstallMessageHandlers();
|
uninstallMessageHandlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public boolean isReceiving() {
|
public boolean isReceiving() {
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
return messageHandlers.size() > 0;
|
return !messageHandlers.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final var contactName = signal.getContactName(n);
|
final var contactName = signal.getContactName(n);
|
||||||
if (onlyContacts && contactName.length() == 0) {
|
if (onlyContacts && contactName.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (name.isPresent() && !name.get().equals(contactName)) {
|
if (name.isPresent() && !name.get().equals(contactName)) {
|
||||||
|
@ -721,7 +721,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
this.notify();
|
this.notify();
|
||||||
}
|
}
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
if (messageHandlers.size() > 0) {
|
if (!messageHandlers.isEmpty()) {
|
||||||
uninstallMessageHandlers();
|
uninstallMessageHandlers();
|
||||||
}
|
}
|
||||||
weakHandlers.clear();
|
weakHandlers.clear();
|
||||||
|
@ -745,7 +745,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
.map(RecipientIdentifier.Single.class::cast)
|
.map(RecipientIdentifier.Single.class::cast)
|
||||||
.map(RecipientIdentifier.Single::getIdentifier)
|
.map(RecipientIdentifier.Single::getIdentifier)
|
||||||
.toList();
|
.toList();
|
||||||
if (singleRecipients.size() > 0) {
|
if (!singleRecipients.isEmpty()) {
|
||||||
timestamp = recipientsHandler.apply(singleRecipients);
|
timestamp = recipientsHandler.apply(singleRecipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
||||||
|
|
||||||
private List<String> getAttachments(MessageEnvelope.Data message) {
|
private List<String> getAttachments(MessageEnvelope.Data message) {
|
||||||
var attachments = new ArrayList<String>();
|
var attachments = new ArrayList<String>();
|
||||||
if (message.attachments().size() > 0) {
|
if (!message.attachments().isEmpty()) {
|
||||||
for (var attachment : message.attachments()) {
|
for (var attachment : message.attachments()) {
|
||||||
if (attachment.file().isPresent()) {
|
if (attachment.file().isPresent()) {
|
||||||
attachments.add(attachment.file().get().getAbsolutePath());
|
attachments.add(attachment.file().get().getAbsolutePath());
|
||||||
|
@ -143,7 +143,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
||||||
|
|
||||||
private HashMap<String, Variant<?>> getMessageExtras(MessageEnvelope.Data message) {
|
private HashMap<String, Variant<?>> getMessageExtras(MessageEnvelope.Data message) {
|
||||||
var extras = new HashMap<String, Variant<?>>();
|
var extras = new HashMap<String, Variant<?>>();
|
||||||
if (message.attachments().size() > 0) {
|
if (!message.attachments().isEmpty()) {
|
||||||
var attachments = message.attachments()
|
var attachments = message.attachments()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(a -> a.id().isPresent())
|
.filter(a -> a.id().isPresent())
|
||||||
|
@ -151,7 +151,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
||||||
.toList();
|
.toList();
|
||||||
extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
|
extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
|
||||||
}
|
}
|
||||||
if (message.mentions().size() > 0) {
|
if (!message.mentions().isEmpty()) {
|
||||||
var mentions = message.mentions().stream().map(this::getMentionMap).toList();
|
var mentions = message.mentions().stream().map(this::getMentionMap).toList();
|
||||||
extras.put("mentions", new Variant<>(mentions, "aa{sv}"));
|
extras.put("mentions", new Variant<>(mentions, "aa{sv}"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ServerSentEventSender {
|
||||||
writer.write(event);
|
writer.write(event);
|
||||||
writer.write("\n");
|
writer.write("\n");
|
||||||
}
|
}
|
||||||
if (data.size() == 0) {
|
if (data.isEmpty()) {
|
||||||
writer.write("data\n");
|
writer.write("data\n");
|
||||||
} else {
|
} else {
|
||||||
for (final var d : data) {
|
for (final var d : data) {
|
||||||
|
|
|
@ -38,27 +38,27 @@ record JsonDataMessage(
|
||||||
final var reaction = dataMessage.reaction().map(JsonReaction::from).orElse(null);
|
final var reaction = dataMessage.reaction().map(JsonReaction::from).orElse(null);
|
||||||
final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
|
final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
|
||||||
final var payment = dataMessage.payment().isPresent() ? JsonPayment.from(dataMessage.payment().get()) : null;
|
final var payment = dataMessage.payment().isPresent() ? JsonPayment.from(dataMessage.payment().get()) : null;
|
||||||
final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
|
final var mentions = !dataMessage.mentions().isEmpty() ? dataMessage.mentions()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonMention::from)
|
.map(JsonMention::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
final var previews = dataMessage.previews().size() > 0 ? dataMessage.previews()
|
final var previews = !dataMessage.previews().isEmpty() ? dataMessage.previews()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonPreview::from)
|
.map(JsonPreview::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
final var remoteDelete = dataMessage.remoteDeleteId().isPresent()
|
final var remoteDelete = dataMessage.remoteDeleteId().isPresent()
|
||||||
? new JsonRemoteDelete(dataMessage.remoteDeleteId().get())
|
? new JsonRemoteDelete(dataMessage.remoteDeleteId().get())
|
||||||
: null;
|
: null;
|
||||||
final var attachments = dataMessage.attachments().size() > 0 ? dataMessage.attachments()
|
final var attachments = !dataMessage.attachments().isEmpty() ? dataMessage.attachments()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonAttachment::from)
|
.map(JsonAttachment::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
final var sticker = dataMessage.sticker().isPresent() ? JsonSticker.from(dataMessage.sticker().get()) : null;
|
final var sticker = dataMessage.sticker().isPresent() ? JsonSticker.from(dataMessage.sticker().get()) : null;
|
||||||
final var contacts = dataMessage.sharedContacts().size() > 0 ? dataMessage.sharedContacts()
|
final var contacts = !dataMessage.sharedContacts().isEmpty() ? dataMessage.sharedContacts()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonSharedContact::from)
|
.map(JsonSharedContact::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
final var textStyles = dataMessage.textStyles().size() > 0 ? dataMessage.textStyles()
|
final var textStyles = !dataMessage.textStyles().isEmpty() ? dataMessage.textStyles()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonTextStyle::from)
|
.map(JsonTextStyle::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
|
|
|
@ -26,16 +26,16 @@ public record JsonQuote(
|
||||||
final var authorUuid = address.uuid().map(UUID::toString).orElse(null);
|
final var authorUuid = address.uuid().map(UUID::toString).orElse(null);
|
||||||
final var text = quote.text().orElse(null);
|
final var text = quote.text().orElse(null);
|
||||||
|
|
||||||
final var mentions = quote.mentions().size() > 0
|
final var mentions = !quote.mentions().isEmpty()
|
||||||
? quote.mentions().stream().map(JsonMention::from).toList()
|
? quote.mentions().stream().map(JsonMention::from).toList()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
final var attachments = quote.attachments().size() > 0 ? quote.attachments()
|
final var attachments = !quote.attachments().isEmpty() ? quote.attachments()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonQuotedAttachment::from)
|
.map(JsonQuotedAttachment::from)
|
||||||
.toList() : List.<JsonQuotedAttachment>of();
|
.toList() : List.<JsonQuotedAttachment>of();
|
||||||
|
|
||||||
final var textStyles = quote.textStyles().size() > 0 ? quote.textStyles()
|
final var textStyles = !quote.textStyles().isEmpty() ? quote.textStyles()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonTextStyle::from)
|
.map(JsonTextStyle::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
|
|
|
@ -19,15 +19,15 @@ public record JsonSharedContact(
|
||||||
final var name = JsonContactName.from(contact.name());
|
final var name = JsonContactName.from(contact.name());
|
||||||
final var avatar = contact.avatar().isPresent() ? JsonContactAvatar.from(contact.avatar().get()) : null;
|
final var avatar = contact.avatar().isPresent() ? JsonContactAvatar.from(contact.avatar().get()) : null;
|
||||||
|
|
||||||
final var phone = contact.phone().size() > 0
|
final var phone = !contact.phone().isEmpty()
|
||||||
? contact.phone().stream().map(JsonContactPhone::from).toList()
|
? contact.phone().stream().map(JsonContactPhone::from).toList()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
final var email = contact.email().size() > 0
|
final var email = !contact.email().isEmpty()
|
||||||
? contact.email().stream().map(JsonContactEmail::from).toList()
|
? contact.email().stream().map(JsonContactEmail::from).toList()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
final var address = contact.address().size() > 0 ? contact.address()
|
final var address = !contact.address().isEmpty() ? contact.address()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonContactAddress::from)
|
.map(JsonContactAddress::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
|
|
|
@ -45,7 +45,7 @@ record JsonSyncMessage(
|
||||||
blockedGroupIds = null;
|
blockedGroupIds = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final var readMessages = syncMessage.read().size() > 0 ? syncMessage.read()
|
final var readMessages = !syncMessage.read().isEmpty() ? syncMessage.read()
|
||||||
.stream()
|
.stream()
|
||||||
.map(JsonSyncReadMessage::from)
|
.map(JsonSyncReadMessage::from)
|
||||||
.toList() : null;
|
.toList() : null;
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class JsonRpcReader {
|
||||||
Util.closeExecutorService(executor);
|
Util.closeExecutorService(executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseList.size() > 0) {
|
if (!responseList.isEmpty()) {
|
||||||
jsonRpcSender.sendBatchResponses(responseList);
|
jsonRpcSender.sendBatchResponses(responseList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ public class JsonRpcReader {
|
||||||
null), null));
|
null), null));
|
||||||
return null;
|
return null;
|
||||||
} else if (jsonNode.isArray()) {
|
} else if (jsonNode.isArray()) {
|
||||||
if (jsonNode.size() == 0) {
|
if (jsonNode.isEmpty()) {
|
||||||
jsonRpcSender.sendResponse(JsonRpcResponse.forError(new JsonRpcResponse.Error(JsonRpcResponse.Error.INVALID_REQUEST,
|
jsonRpcSender.sendResponse(JsonRpcResponse.forError(new JsonRpcResponse.Error(JsonRpcResponse.Error.INVALID_REQUEST,
|
||||||
"invalid request",
|
"invalid request",
|
||||||
null), null));
|
null), null));
|
||||||
|
|
|
@ -41,12 +41,12 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toCamelCaseString(List<String> strings) {
|
private static String toCamelCaseString(List<String> strings) {
|
||||||
if (strings.size() == 0) {
|
if (strings.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return strings.get(0) + strings.stream()
|
return strings.get(0) + strings.stream()
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.filter(s -> s.length() > 0)
|
.filter(s -> !s.isEmpty())
|
||||||
.map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase(Locale.ROOT))
|
.map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase(Locale.ROOT))
|
||||||
.collect(Collectors.joining());
|
.collect(Collectors.joining());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue