Merge "Conistently import Collectors.* statically"
This commit is contained in:
commit
ecf505dc36
@ -21,6 +21,7 @@ import static com.google.gerrit.extensions.restapi.BinaryResultSubject.assertTha
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@ -64,7 +65,6 @@ import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@ -824,7 +824,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
||||
assertThat(ci.messages).isNotNull();
|
||||
assertThat(ci.messages).hasSize(expectedMessages.size());
|
||||
List<String> actualMessages =
|
||||
ci.messages.stream().map(message -> message.message).collect(Collectors.toList());
|
||||
ci.messages.stream().map(message -> message.message).collect(toList());
|
||||
assertThat(actualMessages).containsExactlyElementsIn(expectedMessages).inOrder();
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static com.google.gerrit.extensions.client.ListChangesOption.SUBMITTABLE;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -83,7 +84,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.diff.DiffFormatter;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
@ -464,8 +464,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
|
||||
// Check that the repo has the expected commits
|
||||
List<RevCommit> log = getRemoteLog();
|
||||
List<String> commitsInRepo =
|
||||
log.stream().map(c -> c.getShortMessage()).collect(Collectors.toList());
|
||||
List<String> commitsInRepo = log.stream().map(c -> c.getShortMessage()).collect(toList());
|
||||
int expectedCommitCount =
|
||||
getSubmitType() == SubmitType.MERGE_ALWAYS
|
||||
? 5 // initial commit + 3 commits + merge commit
|
||||
|
@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.rest.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.TruthJUnit.assume;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@ -46,7 +47,6 @@ import com.google.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -272,10 +272,7 @@ public class DraftChangeIT extends AbstractDaemonTest {
|
||||
.get(EnumSet.of(ListChangesOption.ALL_REVISIONS))
|
||||
.revisions
|
||||
.values();
|
||||
return revisionInfos
|
||||
.stream()
|
||||
.map(revisionInfo -> revisionInfo.draft)
|
||||
.collect(Collectors.toList());
|
||||
return revisionInfos.stream().map(revisionInfo -> revisionInfo.draft).collect(toList());
|
||||
}
|
||||
|
||||
private class MarkChangeAsDraftUpdateOp extends BatchUpdate.Op {
|
||||
|
@ -41,7 +41,6 @@ import com.google.gerrit.server.group.GroupsCollection;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -298,14 +297,14 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
setApiUser(user1);
|
||||
String changeId3 = createChangeFromApi();
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(changeId3, null, 4);
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(Collectors.toList()))
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
.containsExactly(reviewer1.id.get(), reviewer2.id.get())
|
||||
.inOrder();
|
||||
|
||||
// check that existing reviewers are filtered out
|
||||
gApi.changes().id(changeId3).addReviewer(reviewer1.email);
|
||||
reviewers = suggestReviewers(changeId3, null, 4);
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(Collectors.toList()))
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
.containsExactly(reviewer2.id.get())
|
||||
.inOrder();
|
||||
}
|
||||
@ -358,7 +357,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
setApiUser(userWhoLooksForSuggestions);
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Pri", 4);
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(Collectors.toList()))
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
.containsExactly(
|
||||
reviewer1.id.get(), reviewer2.id.get(), userWhoOwns.id.get(), userWhoComments.id.get())
|
||||
.inOrder();
|
||||
@ -398,7 +397,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
// Assert that reviewer1 is on top, even though reviewer2 has more reviews
|
||||
// in other projects
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(Collectors.toList()))
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
.containsExactly(reviewer1.id.get(), reviewer2.id.get())
|
||||
.inOrder();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -57,7 +58,6 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.apache.commons.lang.mutable.MutableDouble;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@ -191,7 +191,7 @@ public class ReviewerRecommender {
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
||||
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList());
|
||||
return sortedSuggestions;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import static com.google.gerrit.server.account.ExternalId.SCHEME_USERNAME;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@ -33,7 +34,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
|
||||
public class DeleteExternalIds implements RestModifyView<AccountResource, List<String>> {
|
||||
@ -77,7 +77,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
|
||||
.toList()
|
||||
.stream()
|
||||
.map(ExternalId::from)
|
||||
.collect(Collectors.toMap(i -> i.key(), i -> i));
|
||||
.collect(toMap(i -> i.key(), i -> i));
|
||||
|
||||
List<ExternalId> toDelete = new ArrayList<>();
|
||||
ExternalId.Key last = resource.getUser().getLastLoginExternalIdKey();
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import static com.google.gerrit.server.CommentsUtil.COMMENT_INFO_ORDER;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
@ -38,7 +39,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class CommentJson {
|
||||
|
||||
@ -191,7 +191,7 @@ class CommentJson {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fixSuggestions.stream().map(this::toFixSuggestionInfo).collect(Collectors.toList());
|
||||
return fixSuggestions.stream().map(this::toFixSuggestionInfo).collect(toList());
|
||||
}
|
||||
|
||||
private FixSuggestionInfo toFixSuggestionInfo(FixSuggestion fixSuggestion) {
|
||||
@ -199,11 +199,7 @@ class CommentJson {
|
||||
fixSuggestionInfo.fixId = fixSuggestion.fixId;
|
||||
fixSuggestionInfo.description = fixSuggestion.description;
|
||||
fixSuggestionInfo.replacements =
|
||||
fixSuggestion
|
||||
.replacements
|
||||
.stream()
|
||||
.map(this::toFixReplacementInfo)
|
||||
.collect(Collectors.toList());
|
||||
fixSuggestion.replacements.stream().map(this::toFixReplacementInfo).collect(toList());
|
||||
return fixSuggestionInfo;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
|
||||
@ -112,7 +113,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -885,7 +885,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
}
|
||||
|
||||
private List<FixReplacement> toFixReplacements(List<FixReplacementInfo> fixReplacementInfos) {
|
||||
return fixReplacementInfos.stream().map(this::toFixReplacement).collect(Collectors.toList());
|
||||
return fixReplacementInfos.stream().map(this::toFixReplacement).collect(toList());
|
||||
}
|
||||
|
||||
private FixReplacement toFixReplacement(FixReplacementInfo fixReplacementInfo) {
|
||||
|
@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static java.util.Comparator.comparing;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Joiner;
|
||||
@ -76,7 +77,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@ -500,12 +500,7 @@ public class MergeOp implements AutoCloseable {
|
||||
List<SubmitStrategy> strategies = new ArrayList<>();
|
||||
Set<Branch.NameKey> allBranches = submoduleOp.getBranchesInOrder();
|
||||
Set<CodeReviewCommit> allCommits =
|
||||
toSubmit
|
||||
.values()
|
||||
.stream()
|
||||
.map(BranchBatch::commits)
|
||||
.flatMap(Set::stream)
|
||||
.collect(Collectors.toSet());
|
||||
toSubmit.values().stream().map(BranchBatch::commits).flatMap(Set::stream).collect(toSet());
|
||||
for (Branch.NameKey branch : allBranches) {
|
||||
OpenRepo or = orm.getRepo(branch.getParentKey());
|
||||
if (toSubmit.containsKey(branch)) {
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.mail.receive;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -59,7 +61,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -177,7 +178,7 @@ public class MailProcessor {
|
||||
.stream()
|
||||
.filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000))
|
||||
.sorted(CommentsUtil.COMMENT_ORDER)
|
||||
.collect(Collectors.toList());
|
||||
.collect(toList());
|
||||
Project.NameKey project = cd.project();
|
||||
String changeUrl = canonicalUrl.get() + "#/c/" + cd.getId().get();
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.data.FilenameComparator;
|
||||
@ -48,7 +50,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -527,7 +528,7 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
}
|
||||
return map;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
private boolean hasQuote(List<CommentFormatter.Block> blocks) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
import static org.eclipse.jgit.transport.ReceiveCommand.Type.DELETE;
|
||||
|
||||
@ -31,7 +32,6 @@ import com.google.inject.assistedinject.AssistedInject;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.errors.LockFailedException;
|
||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||
import org.eclipse.jgit.lib.NullProgressMonitor;
|
||||
@ -174,7 +174,7 @@ public class DeleteRef {
|
||||
: refsToDelete
|
||||
.stream()
|
||||
.map(ref -> ref.startsWith(prefix) ? ref : prefix + ref)
|
||||
.collect(Collectors.toList());
|
||||
.collect(toList());
|
||||
for (String ref : refs) {
|
||||
batchUpdate.addCommand(createDeleteCommand(resource, r, ref));
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.gerrit.server.ApprovalsUtil.sortApprovals;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.MoreObjects;
|
||||
@ -83,7 +85,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
@ -108,7 +109,7 @@ public class ChangeData {
|
||||
}
|
||||
|
||||
public static Map<Change.Id, ChangeData> asMap(List<ChangeData> changes) {
|
||||
return changes.stream().collect(Collectors.toMap(ChangeData::getId, cd -> cd));
|
||||
return changes.stream().collect(toMap(ChangeData::getId, cd -> cd));
|
||||
}
|
||||
|
||||
public static void ensureChangeLoaded(Iterable<ChangeData> changes) throws OrmException {
|
||||
@ -999,7 +1000,7 @@ public class ChangeData {
|
||||
|
||||
List<Comment> comments =
|
||||
Stream.concat(publishedComments().stream(), robotComments().stream()).collect(toList());
|
||||
Set<String> nonLeafSet = comments.stream().map(c -> c.parentUuid).collect(Collectors.toSet());
|
||||
Set<String> nonLeafSet = comments.stream().map(c -> c.parentUuid).collect(toSet());
|
||||
|
||||
Long count =
|
||||
comments.stream().filter(c -> (c.unresolved && !nonLeafSet.contains(c.key.uuid))).count();
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
@ -26,7 +28,6 @@ import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@ -70,6 +71,6 @@ public class Schema_130 extends SchemaVersion {
|
||||
}
|
||||
}
|
||||
ui.message("\tMigration completed: " + repoUpgraded.size() + " repositories updated:");
|
||||
ui.message("\t" + repoUpgraded.stream().map(n -> n.get()).collect(Collectors.joining(" ")));
|
||||
ui.message("\t" + repoUpgraded.stream().map(n -> n.get()).collect(joining(" ")));
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
@ -27,7 +29,6 @@ import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@ -70,6 +71,6 @@ public class Schema_131 extends SchemaVersion {
|
||||
}
|
||||
}
|
||||
ui.message("\tMigration completed: " + repoUpgraded.size() + " repositories updated:");
|
||||
ui.message("\t" + repoUpgraded.stream().map(n -> n.get()).collect(Collectors.joining(" ")));
|
||||
ui.message("\t" + repoUpgraded.stream().map(n -> n.get()).collect(joining(" ")));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user