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 {
|
||||
if (!"/".equals(uri.getPath()) && uri.getPath().length() > 0) {
|
||||
if (!"/".equals(uri.getPath()) && !uri.getPath().isEmpty()) {
|
||||
throw new InvalidGroupLinkException("No path was expected in uri");
|
||||
}
|
||||
|
||||
var encoding = uri.getFragment();
|
||||
|
||||
if (encoding == null || encoding.length() == 0) {
|
||||
if (encoding == null || encoding.isEmpty()) {
|
||||
throw new InvalidGroupLinkException("No reference was in the uri");
|
||||
}
|
||||
|
||||
|
|
|
@ -594,14 +594,14 @@ public class GroupHelper {
|
|||
if (members != null) {
|
||||
final var requestingMembers = new HashSet<>(members);
|
||||
requestingMembers.retainAll(group.getRequestingMembers());
|
||||
if (requestingMembers.size() > 0) {
|
||||
if (!requestingMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.approveJoinRequestMembers(group, requestingMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
final var newMembers = new HashSet<>(members);
|
||||
newMembers.removeAll(group.getMembers());
|
||||
newMembers.removeAll(group.getRequestingMembers());
|
||||
if (newMembers.size() > 0) {
|
||||
if (!newMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
@ -617,20 +617,20 @@ public class GroupHelper {
|
|||
existingRemoveMembers.removeAll(members);
|
||||
}
|
||||
existingRemoveMembers.remove(account.getSelfRecipientId());// self can be removed with sendQuitGroupMessage
|
||||
if (existingRemoveMembers.size() > 0) {
|
||||
if (!existingRemoveMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.removeMembers(group, existingRemoveMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
||||
var pendingRemoveMembers = new HashSet<>(removeMembers);
|
||||
pendingRemoveMembers.retainAll(group.getPendingMembers());
|
||||
if (pendingRemoveMembers.size() > 0) {
|
||||
if (!pendingRemoveMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.revokeInvitedMembers(group, pendingRemoveMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
var requestingRemoveMembers = new HashSet<>(removeMembers);
|
||||
requestingRemoveMembers.retainAll(group.getRequestingMembers());
|
||||
if (requestingRemoveMembers.size() > 0) {
|
||||
if (!requestingRemoveMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.refuseJoinRequestMembers(group, requestingRemoveMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ public class GroupHelper {
|
|||
final var newAdmins = new HashSet<>(admins);
|
||||
newAdmins.retainAll(group.getMembers());
|
||||
newAdmins.removeAll(group.getAdminMembers());
|
||||
if (newAdmins.size() > 0) {
|
||||
if (!newAdmins.isEmpty()) {
|
||||
for (var admin : newAdmins) {
|
||||
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, true);
|
||||
result = sendUpdateGroupV2Message(group,
|
||||
|
@ -653,7 +653,7 @@ public class GroupHelper {
|
|||
if (removeAdmins != null) {
|
||||
final var existingRemoveAdmins = new HashSet<>(removeAdmins);
|
||||
existingRemoveAdmins.retainAll(group.getAdminMembers());
|
||||
if (existingRemoveAdmins.size() > 0) {
|
||||
if (!existingRemoveAdmins.isEmpty()) {
|
||||
for (var admin : existingRemoveAdmins) {
|
||||
var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, false);
|
||||
result = sendUpdateGroupV2Message(group,
|
||||
|
@ -666,7 +666,7 @@ public class GroupHelper {
|
|||
if (banMembers != null) {
|
||||
final var newlyBannedMembers = new HashSet<>(banMembers);
|
||||
newlyBannedMembers.removeAll(group.getBannedMembers());
|
||||
if (newlyBannedMembers.size() > 0) {
|
||||
if (!newlyBannedMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.banMembers(group, newlyBannedMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ public class GroupHelper {
|
|||
if (unbanMembers != null) {
|
||||
var existingUnbanMembers = new HashSet<>(unbanMembers);
|
||||
existingUnbanMembers.retainAll(group.getBannedMembers());
|
||||
if (existingUnbanMembers.size() > 0) {
|
||||
if (!existingUnbanMembers.isEmpty()) {
|
||||
var groupGroupChangePair = groupV2Helper.unbanMembers(group, existingUnbanMembers);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ public class GroupHelper {
|
|||
if (currentAdmins.contains(account.getSelfRecipientId())
|
||||
&& currentAdmins.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
|
||||
throw new LastGroupAdminException(groupInfoV2.getGroupId(), groupInfoV2.getTitle());
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ public class SendHelper {
|
|||
: getSenderKeyCapableRecipientIds(recipientIds);
|
||||
final var allResults = new ArrayList<SendMessageResult>(recipientIds.size());
|
||||
|
||||
if (senderKeyTargets.size() > 0) {
|
||||
if (!senderKeyTargets.isEmpty()) {
|
||||
final var results = sendGroupMessageInternalWithSenderKey(senderKeySender,
|
||||
senderKeyTargets,
|
||||
distributionId,
|
||||
|
@ -479,7 +479,7 @@ public class SendHelper {
|
|||
.filter(r -> !r.isSuccess())
|
||||
.map(r -> context.getRecipientHelper().resolveRecipient(r.getAddress()))
|
||||
.toList();
|
||||
if (failedTargets.size() > 0) {
|
||||
if (!failedTargets.isEmpty()) {
|
||||
senderKeyTargets = new HashSet<>(senderKeyTargets);
|
||||
failedTargets.forEach(senderKeyTargets::remove);
|
||||
}
|
||||
|
@ -490,8 +490,8 @@ public class SendHelper {
|
|||
legacyTargets.removeAll(senderKeyTargets);
|
||||
final boolean onlyTargetIsSelfWithLinkedDevice = recipientIds.isEmpty() && account.isMultiDevice();
|
||||
|
||||
if (legacyTargets.size() > 0 || onlyTargetIsSelfWithLinkedDevice) {
|
||||
if (legacyTargets.size() > 0) {
|
||||
if (!legacyTargets.isEmpty() || onlyTargetIsSelfWithLinkedDevice) {
|
||||
if (!legacyTargets.isEmpty()) {
|
||||
logger.debug("Need to do {} legacy sends.", legacyTargets.size());
|
||||
} else {
|
||||
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,
|
||||
legacyTargets,
|
||||
isRecipientUpdate || allResults.size() > 0);
|
||||
isRecipientUpdate || !allResults.isEmpty());
|
||||
allResults.addAll(results);
|
||||
}
|
||||
final var duration = Duration.ofMillis(System.currentTimeMillis() - startTime);
|
||||
|
|
|
@ -298,7 +298,7 @@ public class StorageHelper {
|
|||
logger.warn("Failed to read storage records, ignoring.");
|
||||
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 {
|
||||
|
|
|
@ -663,13 +663,13 @@ public class ManagerImpl implements Manager {
|
|||
} else {
|
||||
messageBuilder.withBody(message.messageText());
|
||||
}
|
||||
if (message.attachments().size() > 0) {
|
||||
if (!message.attachments().isEmpty()) {
|
||||
messageBuilder.withAttachments(context.getAttachmentHelper().uploadAttachments(message.attachments()));
|
||||
}
|
||||
if (message.mentions().size() > 0) {
|
||||
if (!message.mentions().isEmpty()) {
|
||||
messageBuilder.withMentions(resolveMentions(message.mentions()));
|
||||
}
|
||||
if (message.textStyles().size() > 0) {
|
||||
if (!message.textStyles().isEmpty()) {
|
||||
messageBuilder.withBodyRanges(message.textStyles().stream().map(TextStyle::toBodyRange).toList());
|
||||
}
|
||||
if (message.quote().isPresent()) {
|
||||
|
@ -715,7 +715,7 @@ public class ManagerImpl implements Manager {
|
|||
manifestSticker.emoji(),
|
||||
AttachmentUtils.createAttachmentStream(streamDetails, Optional.empty())));
|
||||
}
|
||||
if (message.previews().size() > 0) {
|
||||
if (!message.previews().isEmpty()) {
|
||||
final var previews = new ArrayList<SignalServicePreview>(message.previews().size());
|
||||
for (final var p : message.previews()) {
|
||||
final var image = p.image().isPresent() ? context.getAttachmentHelper()
|
||||
|
@ -874,7 +874,7 @@ public class ManagerImpl implements Manager {
|
|||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
if (recipients.size() == 0) {
|
||||
if (recipients.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final var recipientIds = context.getRecipientHelper().resolveRecipients(recipients);
|
||||
|
@ -906,7 +906,7 @@ public class ManagerImpl implements Manager {
|
|||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
if (groupIds.size() == 0) {
|
||||
if (groupIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean shouldRotateProfileKey = false;
|
||||
|
@ -1083,7 +1083,7 @@ public class ManagerImpl implements Manager {
|
|||
return true;
|
||||
}
|
||||
synchronized (messageHandlers) {
|
||||
return messageHandlers.size() > 0;
|
||||
return !messageHandlers.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1113,7 +1113,7 @@ public class ManagerImpl implements Manager {
|
|||
synchronized (messageHandlers) {
|
||||
receiveThread = null;
|
||||
isReceivingSynchronous = false;
|
||||
if (messageHandlers.size() > 0) {
|
||||
if (!messageHandlers.isEmpty()) {
|
||||
startReceiveThreadIfRequired();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue