Merge "Conistently import Collectors.* statically"

This commit is contained in:
ekempin 2017-03-02 10:37:13 +00:00 committed by Gerrit Code Review
commit ecf505dc36
15 changed files with 39 additions and 48 deletions

View File

@ -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 com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS; 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.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -64,7 +65,6 @@ import java.sql.Timestamp;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@ -824,7 +824,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
assertThat(ci.messages).isNotNull(); assertThat(ci.messages).isNotNull();
assertThat(ci.messages).hasSize(expectedMessages.size()); assertThat(ci.messages).hasSize(expectedMessages.size());
List<String> actualMessages = 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(); assertThat(actualMessages).containsExactlyElementsIn(expectedMessages).inOrder();
} }
} }

View File

@ -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.CHANGE_OWNER;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS; import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -83,7 +84,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import org.eclipse.jgit.diff.DiffFormatter; import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
@ -464,8 +464,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
// Check that the repo has the expected commits // Check that the repo has the expected commits
List<RevCommit> log = getRemoteLog(); List<RevCommit> log = getRemoteLog();
List<String> commitsInRepo = List<String> commitsInRepo = log.stream().map(c -> c.getShortMessage()).collect(toList());
log.stream().map(c -> c.getShortMessage()).collect(Collectors.toList());
int expectedCommitCount = int expectedCommitCount =
getSubmitType() == SubmitType.MERGE_ALWAYS getSubmitType() == SubmitType.MERGE_ALWAYS
? 5 // initial commit + 3 commits + merge commit ? 5 // initial commit + 3 commits + merge commit

View File

@ -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.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume; import static com.google.common.truth.TruthJUnit.assume;
import static java.util.stream.Collectors.toList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.AbstractDaemonTest;
@ -46,7 +47,6 @@ import com.google.inject.Inject;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.junit.Test; import org.junit.Test;
@ -272,10 +272,7 @@ public class DraftChangeIT extends AbstractDaemonTest {
.get(EnumSet.of(ListChangesOption.ALL_REVISIONS)) .get(EnumSet.of(ListChangesOption.ALL_REVISIONS))
.revisions .revisions
.values(); .values();
return revisionInfos return revisionInfos.stream().map(revisionInfo -> revisionInfo.draft).collect(toList());
.stream()
.map(revisionInfo -> revisionInfo.draft)
.collect(Collectors.toList());
} }
private class MarkChangeAsDraftUpdateOp extends BatchUpdate.Op { private class MarkChangeAsDraftUpdateOp extends BatchUpdate.Op {

View File

@ -41,7 +41,6 @@ import com.google.gerrit.server.group.GroupsCollection;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -298,14 +297,14 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
setApiUser(user1); setApiUser(user1);
String changeId3 = createChangeFromApi(); String changeId3 = createChangeFromApi();
List<SuggestedReviewerInfo> reviewers = suggestReviewers(changeId3, null, 4); 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()) .containsExactly(reviewer1.id.get(), reviewer2.id.get())
.inOrder(); .inOrder();
// check that existing reviewers are filtered out // check that existing reviewers are filtered out
gApi.changes().id(changeId3).addReviewer(reviewer1.email); gApi.changes().id(changeId3).addReviewer(reviewer1.email);
reviewers = suggestReviewers(changeId3, null, 4); 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()) .containsExactly(reviewer2.id.get())
.inOrder(); .inOrder();
} }
@ -358,7 +357,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
setApiUser(userWhoLooksForSuggestions); setApiUser(userWhoLooksForSuggestions);
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Pri", 4); 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( .containsExactly(
reviewer1.id.get(), reviewer2.id.get(), userWhoOwns.id.get(), userWhoComments.id.get()) reviewer1.id.get(), reviewer2.id.get(), userWhoOwns.id.get(), userWhoComments.id.get())
.inOrder(); .inOrder();
@ -398,7 +397,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
// Assert that reviewer1 is on top, even though reviewer2 has more reviews // Assert that reviewer1 is on top, even though reviewer2 has more reviews
// in other projects // 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()) .containsExactly(reviewer1.id.get(), reviewer2.id.get())
.inOrder(); .inOrder();
} }

View File

@ -15,6 +15,7 @@
package com.google.gerrit.server; package com.google.gerrit.server;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER; 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.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -57,7 +58,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.lang.mutable.MutableDouble; import org.apache.commons.lang.mutable.MutableDouble;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@ -191,7 +191,7 @@ public class ReviewerRecommender {
.entrySet() .entrySet()
.stream() .stream()
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())); .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; return sortedSuggestions;
} }

View File

@ -15,6 +15,7 @@
package com.google.gerrit.server.account; package com.google.gerrit.server.account;
import static com.google.gerrit.server.account.ExternalId.SCHEME_USERNAME; 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.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
@ -33,7 +34,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
public class DeleteExternalIds implements RestModifyView<AccountResource, List<String>> { public class DeleteExternalIds implements RestModifyView<AccountResource, List<String>> {
@ -77,7 +77,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
.toList() .toList()
.stream() .stream()
.map(ExternalId::from) .map(ExternalId::from)
.collect(Collectors.toMap(i -> i.key(), i -> i)); .collect(toMap(i -> i.key(), i -> i));
List<ExternalId> toDelete = new ArrayList<>(); List<ExternalId> toDelete = new ArrayList<>();
ExternalId.Key last = resource.getUser().getLastLoginExternalIdKey(); ExternalId.Key last = resource.getUser().getLastLoginExternalIdKey();

View File

@ -15,6 +15,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import static com.google.gerrit.server.CommentsUtil.COMMENT_INFO_ORDER; 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.base.Strings;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
@ -38,7 +39,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors;
class CommentJson { class CommentJson {
@ -191,7 +191,7 @@ class CommentJson {
return null; return null;
} }
return fixSuggestions.stream().map(this::toFixSuggestionInfo).collect(Collectors.toList()); return fixSuggestions.stream().map(this::toFixSuggestionInfo).collect(toList());
} }
private FixSuggestionInfo toFixSuggestionInfo(FixSuggestion fixSuggestion) { private FixSuggestionInfo toFixSuggestionInfo(FixSuggestion fixSuggestion) {
@ -199,11 +199,7 @@ class CommentJson {
fixSuggestionInfo.fixId = fixSuggestion.fixId; fixSuggestionInfo.fixId = fixSuggestion.fixId;
fixSuggestionInfo.description = fixSuggestion.description; fixSuggestionInfo.description = fixSuggestion.description;
fixSuggestionInfo.replacements = fixSuggestionInfo.replacements =
fixSuggestion fixSuggestion.replacements.stream().map(this::toFixReplacementInfo).collect(toList());
.replacements
.stream()
.map(this::toFixReplacementInfo)
.collect(Collectors.toList());
return fixSuggestionInfo; return fixSuggestionInfo;
} }

View File

@ -20,6 +20,7 @@ import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER; import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
@ -112,7 +113,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -885,7 +885,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
} }
private List<FixReplacement> toFixReplacements(List<FixReplacementInfo> fixReplacementInfos) { 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) { private FixReplacement toFixReplacement(FixReplacementInfo fixReplacementInfo) {

View File

@ -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.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toSet;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
@ -76,7 +77,6 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@ -500,12 +500,7 @@ public class MergeOp implements AutoCloseable {
List<SubmitStrategy> strategies = new ArrayList<>(); List<SubmitStrategy> strategies = new ArrayList<>();
Set<Branch.NameKey> allBranches = submoduleOp.getBranchesInOrder(); Set<Branch.NameKey> allBranches = submoduleOp.getBranchesInOrder();
Set<CodeReviewCommit> allCommits = Set<CodeReviewCommit> allCommits =
toSubmit toSubmit.values().stream().map(BranchBatch::commits).flatMap(Set::stream).collect(toSet());
.values()
.stream()
.map(BranchBatch::commits)
.flatMap(Set::stream)
.collect(Collectors.toSet());
for (Branch.NameKey branch : allBranches) { for (Branch.NameKey branch : allBranches) {
OpenRepo or = orm.getRepo(branch.getParentKey()); OpenRepo or = orm.getRepo(branch.getParentKey());
if (toSubmit.containsKey(branch)) { if (toSubmit.containsKey(branch)) {

View File

@ -14,6 +14,8 @@
package com.google.gerrit.server.mail.receive; package com.google.gerrit.server.mail.receive;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -59,7 +61,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -177,7 +178,7 @@ public class MailProcessor {
.stream() .stream()
.filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000)) .filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000))
.sorted(CommentsUtil.COMMENT_ORDER) .sorted(CommentsUtil.COMMENT_ORDER)
.collect(Collectors.toList()); .collect(toList());
Project.NameKey project = cd.project(); Project.NameKey project = cd.project();
String changeUrl = canonicalUrl.get() + "#/c/" + cd.getId().get(); String changeUrl = canonicalUrl.get() + "#/c/" + cd.getId().get();

View File

@ -14,6 +14,8 @@
package com.google.gerrit.server.mail.send; package com.google.gerrit.server.mail.send;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.common.data.FilenameComparator; import com.google.gerrit.common.data.FilenameComparator;
@ -48,7 +50,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -527,7 +528,7 @@ public class CommentSender extends ReplyToChangeSender {
} }
return map; return map;
}) })
.collect(Collectors.toList()); .collect(toList());
} }
private boolean hasQuote(List<CommentFormatter.Block> blocks) { private boolean hasQuote(List<CommentFormatter.Block> blocks) {

View File

@ -15,6 +15,7 @@
package com.google.gerrit.server.project; package com.google.gerrit.server.project;
import static java.lang.String.format; 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.lib.Constants.R_TAGS;
import static org.eclipse.jgit.transport.ReceiveCommand.Type.DELETE; 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.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.LockFailedException; import org.eclipse.jgit.errors.LockFailedException;
import org.eclipse.jgit.lib.BatchRefUpdate; import org.eclipse.jgit.lib.BatchRefUpdate;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
@ -174,7 +174,7 @@ public class DeleteRef {
: refsToDelete : refsToDelete
.stream() .stream()
.map(ref -> ref.startsWith(prefix) ? ref : prefix + ref) .map(ref -> ref.startsWith(prefix) ? ref : prefix + ref)
.collect(Collectors.toList()); .collect(toList());
for (String ref : refs) { for (String ref : refs) {
batchUpdate.addCommand(createDeleteCommand(resource, r, ref)); batchUpdate.addCommand(createDeleteCommand(resource, r, ref));
} }

View File

@ -18,6 +18,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.gerrit.server.ApprovalsUtil.sortApprovals; import static com.google.gerrit.server.ApprovalsUtil.sortApprovals;
import static java.util.stream.Collectors.toList; 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.auto.value.AutoValue;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
@ -83,7 +85,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
@ -108,7 +109,7 @@ public class ChangeData {
} }
public static Map<Change.Id, ChangeData> asMap(List<ChangeData> changes) { 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 { public static void ensureChangeLoaded(Iterable<ChangeData> changes) throws OrmException {
@ -999,7 +1000,7 @@ public class ChangeData {
List<Comment> comments = List<Comment> comments =
Stream.concat(publishedComments().stream(), robotComments().stream()).collect(toList()); 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 = Long count =
comments.stream().filter(c -> (c.unresolved && !nonLeafSet.contains(c.key.uuid))).count(); comments.stream().filter(c -> (c.unresolved && !nonLeafSet.contains(c.key.uuid))).count();

View File

@ -14,6 +14,8 @@
package com.google.gerrit.server.schema; 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.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
@ -26,7 +28,6 @@ import com.google.inject.Provider;
import java.io.IOException; import java.io.IOException;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository; 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("\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(" ")));
} }
} }

View File

@ -14,6 +14,8 @@
package com.google.gerrit.server.schema; 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.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
@ -27,7 +29,6 @@ import com.google.inject.Provider;
import java.io.IOException; import java.io.IOException;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository; 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("\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(" ")));
} }
} }