Use Collections.addAll to copy elements from an array to collections

Change-Id: I048d005a0f75b0803be14f2128af682f0f834f8d
This commit is contained in:
Maxime Guerreiro 2018-04-27 13:29:27 +00:00
parent 54f8947d77
commit 87de0c0622
6 changed files with 7 additions and 18 deletions

View File

@ -69,9 +69,7 @@ public class AuthInfo extends JavaScriptObject {
List<AgreementInfo> agreements = new ArrayList<>();
JsArray<AgreementInfo> contributorAgreements = _contributorAgreements();
if (contributorAgreements != null) {
for (AgreementInfo a : Natives.asList(contributorAgreements)) {
agreements.add(a);
}
agreements.addAll(Natives.asList(contributorAgreements));
}
return agreements;
}

View File

@ -31,9 +31,7 @@ public class DownloadInfo extends JavaScriptObject {
public final List<String> archives() {
List<String> archives = new ArrayList<>();
for (String f : Natives.asList(_archives())) {
archives.add(f);
}
archives.addAll(Natives.asList(_archives()));
return archives;
}

View File

@ -1286,9 +1286,7 @@ public abstract class AbstractDaemonTest {
protected void assertDiffForNewFile(
DiffInfo diff, RevCommit commit, String path, String expectedContentSideB) throws Exception {
List<String> expectedLines = new ArrayList<>();
for (String line : expectedContentSideB.split("\n")) {
expectedLines.add(line);
}
Collections.addAll(expectedLines, expectedContentSideB.split("\n"));
assertThat(diff.binary).isNull();
assertThat(diff.changeType).isEqualTo(ChangeType.ADDED);

View File

@ -406,9 +406,7 @@ class Helper {
throw new IllegalArgumentException("No variables in ldap.groupMemberPattern");
}
for (String name : groupMemberQuery.getParameters()) {
accountAtts.add(name);
}
accountAtts.addAll(groupMemberQuery.getParameters());
groupMemberQueryList.add(groupMemberQuery);
}

View File

@ -114,9 +114,7 @@ public class SmtpEmailSender implements EmailSender {
smtpPass = cfg.getString("sendemail", null, "smtppass");
Set<String> rcpt = new HashSet<>();
for (String addr : cfg.getStringList("sendemail", null, "allowrcpt")) {
rcpt.add(addr);
}
Collections.addAll(rcpt, cfg.getStringList("sendemail", null, "allowrcpt"));
allowrcpt = Collections.unmodifiableSet(rcpt);
importance = cfg.getString("sendemail", null, "importance");
expiryDays = cfg.getInt("sendemail", null, "expiryDays", 0);

View File

@ -53,6 +53,7 @@ import com.google.gerrit.testing.FakeEmailSender.Message;
import com.google.gson.stream.JsonReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -839,9 +840,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
private static void assertReviewers(
ChangeInfo c, ReviewerState reviewerState, TestAccount... accounts) throws Exception {
List<TestAccount> accountList = new ArrayList<>(accounts.length);
for (TestAccount a : accounts) {
accountList.add(a);
}
Collections.addAll(accountList, accounts);
assertReviewers(c, reviewerState, accountList);
}