Prefer subtypes of Multimap

Guava team recommends using the subinterfaces of Multimap, for the
same reasons they recommend using Set and List rather than Collection:
it documents expectations about ordering, uniqueness, and behavior of
equals. Do this across the board in Gerrit.

Mostly this is straightforward and I tried to exactly match existing
behavior where possible. However, there were a few wrinkles, where
different callers passed different subtypes to the same method.

The main one is arguments to ParameterParser#parse and
splitQueryString, where some callers used SetMultimaps (perhaps
semi-intentionally, or perhaps misunderstanding the nature of
HashMultimap). For the purposes of parameter parsing, a ListMultimap
makes more sense, because it preserves argument order and repetition.

Another instance is a couple places in ReceiveCommits and downstream
where there were SetMultimap<?, Ref>. Since Refs do not implement
equals, this is effectively the same thing as a ListMultimap, and
changing the interface no longer misleads readers into thinking there
might be some deduplication happening.

Finally, this change includes a breaking API change to the return
type of ExternalIncludedIn#getIncludedIn.

Change-Id: I5f1d15e27a32e534a6aaefe204e7a31815f4c8d7
This commit is contained in:
Dave Borowitz
2017-01-13 16:26:45 -05:00
committed by David Pursehouse
parent e5c5953205
commit 484da493b3
76 changed files with 367 additions and 355 deletions

View File

@@ -17,22 +17,22 @@ package com.google.gerrit.audit;
import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.server.CurrentUser;
public class AuditEvent {
public static final String UNKNOWN_SESSION_ID = "000000000000000000000000000";
protected static final Multimap<String, ?> EMPTY_PARAMS =
MultimapBuilder.hashKeys().hashSetValues().build();
protected static final ListMultimap<String, ?> EMPTY_PARAMS =
ImmutableListMultimap.of();
public final String sessionId;
public final CurrentUser who;
public final long when;
public final String what;
public final Multimap<String, ?> params;
public final ListMultimap<String, ?> params;
public final Object result;
public final long timeAtStart;
public final long elapsed;
@@ -59,7 +59,7 @@ public class AuditEvent {
* @param result result of the event
*/
public AuditEvent(String sessionId, CurrentUser who, String what, long when,
Multimap<String, ?> params, Object result) {
ListMultimap<String, ?> params, Object result) {
Preconditions.checkNotNull(what, "what is a mandatory not null param !");
this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.audit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.server.CurrentUser;
@@ -45,11 +45,11 @@ public class ExtendedHttpAuditEvent extends HttpAuditEvent {
* @param view view rendering object
*/
public ExtendedHttpAuditEvent(String sessionId, CurrentUser who,
HttpServletRequest httpRequest, long when, Multimap<String, ?> params,
HttpServletRequest httpRequest, long when, ListMultimap<String, ?> params,
Object input, int status, Object result, RestResource resource,
RestView<RestResource> view) {
super(sessionId, who, httpRequest.getRequestURI(), when, params, httpRequest.getMethod(),
input, status, result);
super(sessionId, who, httpRequest.getRequestURI(), when, params,
httpRequest.getMethod(), input, status, result);
this.httpRequest = Preconditions.checkNotNull(httpRequest);
this.resource = resource;
this.view = view;

View File

@@ -13,7 +13,7 @@
// limitations under the License.
package com.google.gerrit.audit;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser;
public class HttpAuditEvent extends AuditEvent {
@@ -34,8 +34,9 @@ public class HttpAuditEvent extends AuditEvent {
* @param status HTTP status
* @param result result of the event
*/
public HttpAuditEvent(String sessionId, CurrentUser who, String what, long when,
Multimap<String, ?> params, String httpMethod, Object input, int status, Object result) {
public HttpAuditEvent(String sessionId, CurrentUser who, String what,
long when, ListMultimap<String, ?> params, String httpMethod,
Object input, int status, Object result) {
super(sessionId, who, what, when, params, result);
this.httpMethod = httpMethod;
this.input = input;

View File

@@ -11,9 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.audit;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser;
public class RpcAuditEvent extends HttpAuditEvent {
@@ -32,8 +33,8 @@ public class RpcAuditEvent extends HttpAuditEvent {
* @param result result of the event
*/
public RpcAuditEvent(String sessionId, CurrentUser who, String what,
long when, Multimap<String, ?> params, String httpMethod, Object input,
int status, Object result) {
long when, ListMultimap<String, ?> params, String httpMethod,
Object input, int status, Object result) {
super(sessionId, who, what, when, params, httpMethod, input, status, result);
}
}

View File

@@ -11,15 +11,16 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.audit;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser;
public class SshAuditEvent extends AuditEvent {
public SshAuditEvent(String sessionId, CurrentUser who, String what,
long when, Multimap<String, ?> params, Object result) {
long when, ListMultimap<String, ?> params, Object result) {
super(sessionId, who, what, when, params, result);
}
}

View File

@@ -11,10 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.rules;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import com.google.gerrit.extensions.registration.DynamicSet;
import java.util.Collection;
@@ -24,7 +25,7 @@ import java.util.Collection;
*/
public class PredicateClassLoader extends ClassLoader {
private final Multimap<String, ClassLoader> packageClassLoaderMap =
private final SetMultimap<String, ClassLoader> packageClassLoaderMap =
LinkedHashMultimap.create();
public PredicateClassLoader(

View File

@@ -23,8 +23,8 @@ import com.google.auto.value.AutoValue;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.primitives.Ints;
@@ -314,7 +314,7 @@ public class StarredChangesUtil {
}
}
public ImmutableMultimap<Account.Id, String> byChangeFromIndex(
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(
Change.Id changeId) throws OrmException {
Set<String> fields = ImmutableSet.of(
ChangeField.ID.getName(),

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.account;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountExternalId;
@@ -76,7 +76,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onCreate(Iterable<AccountExternalId> extIds) {
lock.lock();
try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : extIds) {
n.put(extId.getAccountId(), extId);
@@ -93,7 +93,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onRemove(Iterable<AccountExternalId> extIds) {
lock.lock();
try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : extIds) {
n.remove(extId.getAccountId(), extId);
@@ -111,7 +111,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
Iterable<AccountExternalId.Key> extIdKeys) {
lock.lock();
try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : byAccount(accountId)) {
for (AccountExternalId.Key extIdKey : extIdKeys) {
@@ -133,7 +133,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onUpdate(AccountExternalId updatedExtId) {
lock.lock();
try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : byAccount(updatedExtId.getAccountId())) {
if (updatedExtId.getKey().equals(extId.getKey())) {
@@ -181,7 +181,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public ImmutableSetMultimap<Account.Id, AccountExternalId> load(AllKey key)
throws Exception {
try (ReviewDb db = schema.open()) {
Multimap<Account.Id, AccountExternalId> extIdsByAccount =
ListMultimap<Account.Id, AccountExternalId> extIdsByAccount =
MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountExternalId extId : db.accountExternalIds().all()) {
extIdsByAccount.put(extId.getAccountId(), extId);

View File

@@ -18,7 +18,7 @@ import static com.google.gerrit.server.account.GroupBackends.GROUP_REF_NAME_COMP
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
@@ -138,7 +138,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override
public boolean containsAnyOf(Iterable<AccountGroup.UUID> uuids) {
Multimap<GroupMembership, AccountGroup.UUID> lookups =
ListMultimap<GroupMembership, AccountGroup.UUID> lookups =
MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountGroup.UUID uuid : uuids) {
if (uuid == null) {
@@ -168,7 +168,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override
public Set<AccountGroup.UUID> intersection(Iterable<AccountGroup.UUID> uuids) {
Multimap<GroupMembership, AccountGroup.UUID> lookups =
ListMultimap<GroupMembership, AccountGroup.UUID> lookups =
MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountGroup.UUID uuid : uuids) {
if (uuid == null) {

View File

@@ -25,7 +25,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
@@ -269,7 +269,7 @@ public class WatchConfig extends VersionedMetaData
cfg.unsetSection(PROJECT, projectName);
}
Multimap<String, String> notifyValuesByProject =
ListMultimap<String, String> notifyValuesByProject =
MultimapBuilder.hashKeys().arrayListValues().build();
for (Map.Entry<ProjectWatchKey, Set<NotifyType>> e : projectWatches
.entrySet()) {

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
@@ -95,7 +95,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
public Change abandon(ChangeControl control, String msgTxt,
NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify)
ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws RestApiException, UpdateException {
CurrentUser user = control.getUser();
Account account = user.isIdentifiedUser()
@@ -125,7 +125,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
public void batchAbandon(Project.NameKey project, CurrentUser user,
Collection<ChangeControl> controls, String msgTxt,
NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify)
ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws RestApiException, UpdateException {
if (controls.isEmpty()) {
return;

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.InternalUser;
import com.google.gerrit.server.config.ChangeCleanupConfig;
@@ -78,15 +78,15 @@ public class AbandonUtil {
.enforceVisibility(false)
.query(queryBuilder.parse(query))
.entities();
ImmutableMultimap.Builder<Project.NameKey, ChangeControl> builder =
ImmutableMultimap.builder();
ImmutableListMultimap.Builder<Project.NameKey, ChangeControl> builder =
ImmutableListMultimap.builder();
for (ChangeData cd : changesToAbandon) {
ChangeControl control = cd.changeControl(internalUser);
builder.put(control.getProject().getNameKey(), control);
}
int count = 0;
Multimap<Project.NameKey, ChangeControl> abandons = builder.build();
ListMultimap<Project.NameKey, ChangeControl> abandons = builder.build();
String message = cfg.getAbandonMessage();
for (Project.NameKey project : abandons.keySet()) {
Collection<ChangeControl> changes =

View File

@@ -21,7 +21,7 @@ import static java.util.stream.Collectors.toSet;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes;
@@ -114,7 +114,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
private CommitValidators.Policy validatePolicy =
CommitValidators.Policy.GERRIT;
private NotifyHandling notify = NotifyHandling.ALL;
private Multimap<RecipientType, Account.Id> accountsToNotify =
private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of();
private Set<Account.Id> reviewers;
private Set<Account.Id> extraCC;
@@ -240,7 +240,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
}
public ChangeInserter setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify);
return this;
}

View File

@@ -50,7 +50,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
@@ -821,7 +820,7 @@ public class ChangeJson {
}
Set<String> labelNames = new HashSet<>();
Multimap<Account.Id, PatchSetApproval> current =
SetMultimap<Account.Id, PatchSetApproval> current =
MultimapBuilder.hashKeys().hashSetValues().build();
for (PatchSetApproval a : cd.currentApprovals()) {
allUsers.add(a.getAccountId());

View File

@@ -23,8 +23,8 @@ import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
import com.google.auto.value.AutoValue;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil;
@@ -126,7 +126,7 @@ public class ConsistencyChecker {
private RevWalk rw;
private RevCommit tip;
private Multimap<ObjectId, PatchSet> patchSetsBySha;
private SetMultimap<ObjectId, PatchSet> patchSetsBySha;
private PatchSet currPs;
private RevCommit currPsCommit;

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -53,7 +53,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
interface Factory {
EmailReviewComments create(
NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify,
ListMultimap<RecipientType, Account.Id> accountsToNotify,
ChangeNotes notes,
PatchSet patchSet,
IdentifiedUser user,
@@ -70,7 +70,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
private final ThreadLocalRequestContext requestContext;
private final NotifyHandling notify;
private final Multimap<RecipientType, Account.Id> accountsToNotify;
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final ChangeNotes notes;
private final PatchSet patchSet;
private final IdentifiedUser user;
@@ -88,7 +88,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
SchemaFactory<ReviewDb> schemaFactory,
ThreadLocalRequestContext requestContext,
@Assisted NotifyHandling notify,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify,
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify,
@Assisted ChangeNotes notes,
@Assisted PatchSet patchSet,
@Assisted IdentifiedUser user,

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.change;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.extensions.config.ExternalIncludedIn;
import com.google.gerrit.extensions.registration.DynamicSet;
@@ -81,10 +81,10 @@ class IncludedIn implements RestReadView<ChangeResource> {
}
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
Multimap<String, String> external =
ListMultimap<String, String> external =
MultimapBuilder.hashKeys().arrayListValues().build();
for (ExternalIncludedIn ext : includedIn) {
Multimap<String, String> extIncludedIns = ext.getIncludedIn(
ListMultimap<String, String> extIncludedIns = ext.getIncludedIn(
project.get(), rev.name(), d.getTags(), d.getBranches());
if (extIncludedIns != null) {
external.putAll(extIncludedIns);

View File

@@ -15,8 +15,8 @@
package com.google.gerrit.server.change;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -76,7 +76,7 @@ public class IncludedInResolver {
private final RevCommit target;
private final RevFlag containsTarget;
private Multimap<RevCommit, String> commitToRef;
private ListMultimap<RevCommit, String> commitToRef;
private List<RevCommit> tipsByCommitTime;
private IncludedInResolver(Repository repo, RevWalk rw, RevCommit target,

View File

@@ -18,7 +18,7 @@ import static java.util.stream.Collectors.joining;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.NotifyInfo;
@@ -77,14 +77,14 @@ public class NotifyUtil {
return notifyInfo.accounts == null || notifyInfo.accounts.isEmpty();
}
public Multimap<RecipientType, Account.Id> resolveAccounts(
public ListMultimap<RecipientType, Account.Id> resolveAccounts(
@Nullable Map<RecipientType, NotifyInfo> notifyDetails)
throws OrmException, BadRequestException {
if (isNullOrEmpty(notifyDetails)) {
return ImmutableListMultimap.of();
}
Multimap<RecipientType, Account.Id> m = null;
ListMultimap<RecipientType, Account.Id> m = null;
for (Entry<RecipientType, NotifyInfo> e : notifyDetails.entrySet()) {
List<String> accounts = e.getValue().accounts;
if (accounts != null) {

View File

@@ -20,7 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.extensions.restapi.AuthException;
@@ -100,7 +100,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
private List<String> groups = Collections.emptyList();
private boolean fireRevisionCreated = true;
private NotifyHandling notify = NotifyHandling.ALL;
private Multimap<RecipientType, Account.Id> accountsToNotify =
private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of();
private boolean allowClosed;
private boolean copyApprovals = true;
@@ -185,7 +185,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
}
public PatchSetInserter setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify);
return this;
}

View File

@@ -27,9 +27,9 @@ import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
@@ -207,7 +207,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
input.notify = NotifyHandling.NONE;
}
Multimap<RecipientType, Account.Id> accountsToNotify =
ListMultimap<RecipientType, Account.Id> accountsToNotify =
notifyUtil.resolveAccounts(input.notifyDetails);
Map<String, AddReviewerResult> reviewerJsonResults = null;
@@ -304,7 +304,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private void emailReviewers(Change change,
List<PostReviewers.Addition> reviewerAdditions, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
List<Account.Id> to = new ArrayList<>();
List<Account.Id> cc = new ArrayList<>();
for (PostReviewers.Addition addition : reviewerAdditions) {
@@ -671,7 +671,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private class Op extends BatchUpdate.Op {
private final PatchSet.Id psId;
private final ReviewInput in;
private final Multimap<RecipientType, Account.Id> accountsToNotify;
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final List<PostReviewers.Addition> reviewerResults;
private IdentifiedUser user;
@@ -684,7 +684,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private Map<String, Short> oldApprovals = new HashMap<>();
private Op(PatchSet.Id psId, ReviewInput in,
Multimap<RecipientType, Account.Id> accountsToNotify,
ListMultimap<RecipientType, Account.Id> accountsToNotify,
List<PostReviewers.Addition> reviewerResults) {
this.psId = psId;
this.in = in;

View File

@@ -21,8 +21,8 @@ import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.NoSuchGroupException;
@@ -201,7 +201,7 @@ public class PostReviewers
private Addition putAccount(String reviewer, ReviewerResource rsrc,
ReviewerState state, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify)
ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws UnprocessableEntityException {
Account member = rsrc.getReviewerUser().getAccount();
ChangeControl control = rsrc.getReviewerControl();
@@ -303,7 +303,7 @@ public class PostReviewers
protected Addition(String reviewer, ChangeResource rsrc,
Map<Account.Id, ChangeControl> reviewers, ReviewerState state,
NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
result = new AddReviewerResult(reviewer);
if (reviewers == null) {
this.reviewers = ImmutableMap.of();
@@ -342,7 +342,7 @@ public class PostReviewers
final Map<Account.Id, ChangeControl> reviewers;
final ReviewerState state;
final NotifyHandling notify;
final Multimap<RecipientType, Account.Id> accountsToNotify;
final ListMultimap<RecipientType, Account.Id> accountsToNotify;
List<PatchSetApproval> addedReviewers;
Collection<Account.Id> addedCCs;
@@ -351,7 +351,7 @@ public class PostReviewers
Op(ChangeResource rsrc, Map<Account.Id, ChangeControl> reviewers,
ReviewerState state, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.rsrc = rsrc;
this.reviewers = reviewers;
this.state = state;
@@ -407,7 +407,7 @@ public class PostReviewers
public void emailReviewers(Change change, Collection<Account.Id> added,
Collection<Account.Id> copied, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
if (added.isEmpty() && copied.isEmpty()) {
return;
}

View File

@@ -21,7 +21,7 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.ParameterizedString;
import com.google.gerrit.extensions.api.changes.SubmitInput;
@@ -418,7 +418,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
mergeabilityMap.add(change);
}
Multimap<Branch.NameKey, ChangeData> cbb = cs.changesByBranch();
ListMultimap<Branch.NameKey, ChangeData> cbb = cs.changesByBranch();
for (Branch.NameKey branch : cbb.keySet()) {
Collection<ChangeData> targetBranch = cbb.get(branch);
HashMap<Change.Id, RevCommit> commits =

View File

@@ -20,7 +20,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -105,7 +105,7 @@ class WalkSorter {
public Iterable<PatchSetData> sort(Iterable<ChangeData> in)
throws OrmException, IOException {
Multimap<Project.NameKey, ChangeData> byProject =
ListMultimap<Project.NameKey, ChangeData> byProject =
MultimapBuilder.hashKeys().arrayListValues().build();
for (ChangeData cd : in) {
byProject.put(cd.change().getProject(), cd);
@@ -126,7 +126,7 @@ class WalkSorter {
try (Repository repo = repoManager.openRepository(project);
RevWalk rw = new RevWalk(repo)) {
rw.setRetainBody(retainBody);
Multimap<RevCommit, PatchSetData> byCommit = byCommit(rw, in);
ListMultimap<RevCommit, PatchSetData> byCommit = byCommit(rw, in);
if (byCommit.isEmpty()) {
return ImmutableList.of();
} else if (byCommit.size() == 1) {
@@ -151,8 +151,8 @@ class WalkSorter {
// the input size is small enough that this is not an issue.)
Set<RevCommit> commits = byCommit.keySet();
Multimap<RevCommit, RevCommit> children = collectChildren(commits);
Multimap<RevCommit, RevCommit> pending =
ListMultimap<RevCommit, RevCommit> children = collectChildren(commits);
ListMultimap<RevCommit, RevCommit> pending =
MultimapBuilder.hashKeys().arrayListValues().build();
Deque<RevCommit> todo = new ArrayDeque<>();
@@ -195,9 +195,9 @@ class WalkSorter {
}
}
private static Multimap<RevCommit, RevCommit> collectChildren(
private static ListMultimap<RevCommit, RevCommit> collectChildren(
Set<RevCommit> commits) {
Multimap<RevCommit, RevCommit> children =
ListMultimap<RevCommit, RevCommit> children =
MultimapBuilder.hashKeys().arrayListValues().build();
for (RevCommit c : commits) {
for (RevCommit p : c.getParents()) {
@@ -209,8 +209,9 @@ class WalkSorter {
return children;
}
private static int emit(RevCommit c, Multimap<RevCommit, PatchSetData> byCommit,
List<PatchSetData> result, RevFlag done) {
private static int emit(RevCommit c,
ListMultimap<RevCommit, PatchSetData> byCommit, List<PatchSetData> result,
RevFlag done) {
if (c.has(done)) {
return 0;
}
@@ -223,9 +224,9 @@ class WalkSorter {
return 0;
}
private Multimap<RevCommit, PatchSetData> byCommit(RevWalk rw,
private ListMultimap<RevCommit, PatchSetData> byCommit(RevWalk rw,
Collection<ChangeData> in) throws OrmException, IOException {
Multimap<RevCommit, PatchSetData> byCommit =
ListMultimap<RevCommit, PatchSetData> byCommit =
MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build();
for (ChangeData cd : in) {
PatchSet maxPs = null;

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.config;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import org.eclipse.jgit.revwalk.FooterLine;
@@ -37,8 +37,8 @@ public class TrackingFooters {
return trackingFooters.isEmpty();
}
public Multimap<String, String> extract(List<FooterLine> lines) {
Multimap<String, String> r = ArrayListMultimap.create();
public ListMultimap<String, String> extract(List<FooterLine> lines) {
ListMultimap<String, String> r = ArrayListMultimap.create();
if (lines == null) {
return r;
}

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.edit;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -171,7 +171,7 @@ public class ChangeEditUtil {
* @throws RestApiException
*/
public void publish(final ChangeEdit edit, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify)
ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws IOException, OrmException, RestApiException, UpdateException {
Change change = edit.getChange();
try (Repository repo = gitManager.openRepository(change.getProject());

View File

@@ -17,8 +17,8 @@ package com.google.gerrit.server.events;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Comparator.comparing;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes;
@@ -354,7 +354,8 @@ public class EventFactory {
return d;
}
public void addTrackingIds(ChangeAttribute a, Multimap<String, String> set) {
public void addTrackingIds(ChangeAttribute a,
ListMultimap<String, String> set) {
if (!set.isEmpty()) {
a.trackingIds = new ArrayList<>(set.size());
for (Map.Entry<String, Collection<String>> e : set.asMap().entrySet()) {

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.git;
import com.google.common.base.Strings;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -49,7 +49,7 @@ public class AbandonOp extends BatchUpdate.Op {
private final String msgTxt;
private final NotifyHandling notifyHandling;
private final Multimap<RecipientType, Account.Id> accountsToNotify;
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final Account account;
private Change change;
@@ -61,7 +61,7 @@ public class AbandonOp extends BatchUpdate.Op {
@Assisted @Nullable Account account,
@Assisted @Nullable String msgTxt,
@Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify);
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify);
}
@AssistedInject
@@ -73,7 +73,7 @@ public class AbandonOp extends BatchUpdate.Op {
@Assisted @Nullable Account account,
@Assisted @Nullable String msgTxt,
@Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify) {
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.abandonedSenderFactory = abandonedSenderFactory;
this.cmUtil = cmUtil;
this.psUtil = psUtil;

View File

@@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
@@ -82,7 +81,7 @@ public class ChangeSet {
return changeData;
}
public Multimap<Branch.NameKey, ChangeData> changesByBranch()
public ListMultimap<Branch.NameKey, ChangeData> changesByBranch()
throws OrmException {
ListMultimap<Branch.NameKey, ChangeData> ret =
MultimapBuilder.hashKeys().arrayListValues().build();

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.git;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -46,7 +46,7 @@ public class EmailMerge implements Runnable, RequestContext {
public interface Factory {
EmailMerge create(Project.NameKey project, Change.Id changeId,
Account.Id submitter, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify);
ListMultimap<RecipientType, Account.Id> accountsToNotify);
}
private final ExecutorService sendEmailsExecutor;
@@ -59,7 +59,7 @@ public class EmailMerge implements Runnable, RequestContext {
private final Change.Id changeId;
private final Account.Id submitter;
private final NotifyHandling notifyHandling;
private final Multimap<RecipientType, Account.Id> accountsToNotify;
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private ReviewDb db;
@@ -73,7 +73,7 @@ public class EmailMerge implements Runnable, RequestContext {
@Assisted Change.Id changeId,
@Assisted @Nullable Account.Id submitter,
@Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify) {
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.sendEmailsExecutor = executor;
this.mergedSenderFactory = mergedSenderFactory;
this.schemaFactory = schemaFactory;

View File

@@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
@@ -103,16 +102,16 @@ public class GroupCollector {
List<String> lookup(PatchSet.Id psId) throws OrmException;
}
private final Multimap<ObjectId, PatchSet.Id> patchSetsBySha;
private final Multimap<ObjectId, String> groups;
private final ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha;
private final ListMultimap<ObjectId, String> groups;
private final SetMultimap<String, String> groupAliases;
private final Lookup groupLookup;
private boolean done;
public static GroupCollector create(Multimap<ObjectId, Ref> changeRefsById,
final ReviewDb db, final PatchSetUtil psUtil,
final ChangeNotes.Factory notesFactory, final Project.NameKey project) {
public static GroupCollector create(ListMultimap<ObjectId, Ref> changeRefsById,
ReviewDb db, PatchSetUtil psUtil, ChangeNotes.Factory notesFactory,
Project.NameKey project) {
return new GroupCollector(
transformRefs(changeRefsById),
new Lookup() {
@@ -128,7 +127,7 @@ public class GroupCollector {
}
public static GroupCollector createForSchemaUpgradeOnly(
Multimap<ObjectId, Ref> changeRefsById, final ReviewDb db) {
ListMultimap<ObjectId, Ref> changeRefsById, ReviewDb db) {
return new GroupCollector(
transformRefs(changeRefsById),
new Lookup() {
@@ -141,7 +140,7 @@ public class GroupCollector {
}
private GroupCollector(
Multimap<ObjectId, PatchSet.Id> patchSetsBySha,
ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha,
Lookup groupLookup) {
this.patchSetsBySha = patchSetsBySha;
this.groupLookup = groupLookup;
@@ -149,16 +148,16 @@ public class GroupCollector {
groupAliases = MultimapBuilder.hashKeys().hashSetValues().build();
}
private static Multimap<ObjectId, PatchSet.Id> transformRefs(
Multimap<ObjectId, Ref> refs) {
private static ListMultimap<ObjectId, PatchSet.Id> transformRefs(
ListMultimap<ObjectId, Ref> refs) {
return Multimaps.transformValues(
refs, r -> PatchSet.Id.fromRef(r.getName()));
}
@VisibleForTesting
GroupCollector(
Multimap<ObjectId, PatchSet.Id> patchSetsBySha,
final ListMultimap<PatchSet.Id, String> groupLookup) {
ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha,
ListMultimap<PatchSet.Id, String> groupLookup) {
this(
patchSetsBySha,
new Lookup() {

View File

@@ -21,12 +21,13 @@ import static java.util.Comparator.comparing;
import com.google.auto.value.AutoValue;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil;
@@ -109,7 +110,7 @@ public class MergeOp implements AutoCloseable {
private final ImmutableMap<Change.Id, ChangeData> changes;
private final ImmutableSetMultimap<Branch.NameKey, Change.Id> byBranch;
private final Map<Change.Id, CodeReviewCommit> commits;
private final Multimap<Change.Id, String> problems;
private final ListMultimap<Change.Id, String> problems;
private CommitStatus(ChangeSet cs) throws OrmException {
checkArgument(!cs.furtherHiddenChanges(),
@@ -163,8 +164,8 @@ public class MergeOp implements AutoCloseable {
return problems.isEmpty();
}
public ImmutableMultimap<Change.Id, String> getProblems() {
return ImmutableMultimap.copyOf(problems);
public ImmutableListMultimap<Change.Id, String> getProblems() {
return ImmutableListMultimap.copyOf(problems);
}
public List<SubmitRecord> getSubmitRecords(Change.Id id) {
@@ -228,7 +229,7 @@ public class MergeOp implements AutoCloseable {
private CommitStatus commits;
private ReviewDb db;
private SubmitInput submitInput;
private Multimap<RecipientType, Account.Id> accountsToNotify;
private ListMultimap<RecipientType, Account.Id> accountsToNotify;
private Set<Project.NameKey> allProjects;
private boolean dryrun;
@@ -452,7 +453,7 @@ public class MergeOp implements AutoCloseable {
logDebug("Beginning merge attempt on {}", cs);
Map<Branch.NameKey, BranchBatch> toSubmit = new HashMap<>();
Multimap<Branch.NameKey, ChangeData> cbb;
ListMultimap<Branch.NameKey, ChangeData> cbb;
try {
cbb = cs.changesByBranch();
} catch (OrmException e) {
@@ -596,7 +597,7 @@ public class MergeOp implements AutoCloseable {
Collection<ChangeData> submitted) throws IntegrationException {
logDebug("Validating {} changes", submitted.size());
List<ChangeData> toSubmit = new ArrayList<>(submitted.size());
Multimap<ObjectId, PatchSet.Id> revisions = getRevisions(or, submitted);
SetMultimap<ObjectId, PatchSet.Id> revisions = getRevisions(or, submitted);
SubmitType submitType = null;
ChangeData choseSubmitTypeFrom = null;
@@ -696,7 +697,7 @@ public class MergeOp implements AutoCloseable {
return new AutoValue_MergeOp_BranchBatch(submitType, toSubmit);
}
private Multimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or,
private SetMultimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or,
Collection<ChangeData> cds) throws IntegrationException {
try {
List<String> refNames = new ArrayList<>(cds.size());
@@ -706,7 +707,7 @@ public class MergeOp implements AutoCloseable {
refNames.add(c.currentPatchSetId().toRefName());
}
}
Multimap<ObjectId, PatchSet.Id> revisions =
SetMultimap<ObjectId, PatchSet.Id> revisions =
MultimapBuilder.hashKeys(cds.size()).hashSetValues(1).build();
for (Map.Entry<String, Ref> e : or.repo.getRefDatabase().exactRef(
refNames.toArray(new String[refNames.size()])).entrySet()) {

View File

@@ -44,9 +44,7 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.common.collect.SortedSetMultimap;
import com.google.gerrit.common.Nullable;
@@ -325,7 +323,7 @@ public class ReceiveCommits {
private final Set<ObjectId> validCommits = new HashSet<>();
private ListMultimap<Change.Id, Ref> refsByChange;
private SetMultimap<ObjectId, Ref> refsById;
private ListMultimap<ObjectId, Ref> refsById;
private Map<String, Ref> allRefs;
private final SubmoduleOp.Factory subOpFactory;
@@ -1325,8 +1323,8 @@ public class ReceiveCommits {
return new MailRecipients(reviewer, cc);
}
Multimap<RecipientType, Account.Id> getAccountsToNotify() {
Multimap<RecipientType, Account.Id> accountsToNotify =
ListMultimap<RecipientType, Account.Id> getAccountsToNotify() {
ListMultimap<RecipientType, Account.Id> accountsToNotify =
MultimapBuilder.hashKeys().arrayListValues().build();
accountsToNotify.putAll(RecipientType.TO, tos);
accountsToNotify.putAll(RecipientType.CC, ccs);
@@ -1673,8 +1671,9 @@ public class ReceiveCommits {
logDebug("Finding new and replaced changes");
newChanges = new ArrayList<>();
SetMultimap<ObjectId, Ref> existing = changeRefsById();
GroupCollector groupCollector = GroupCollector.create(changeRefsById(), db, psUtil,
ListMultimap<ObjectId, Ref> existing = changeRefsById();
GroupCollector groupCollector = GroupCollector.create(
changeRefsById(), db, psUtil,
notesFactory, project.getNameKey());
try {
@@ -2527,7 +2526,7 @@ public class ReceiveCommits {
private void initChangeRefMaps() {
if (refsByChange == null) {
int estRefsPerChange = 4;
refsById = MultimapBuilder.hashKeys().hashSetValues().build();
refsById = MultimapBuilder.hashKeys().arrayListValues().build();
refsByChange =
MultimapBuilder.hashKeys(allRefs.size() / estRefsPerChange)
.arrayListValues(estRefsPerChange)
@@ -2550,7 +2549,7 @@ public class ReceiveCommits {
return refsByChange;
}
private SetMultimap<ObjectId, Ref> changeRefsById() {
private ListMultimap<ObjectId, Ref> changeRefsById() {
initChangeRefMaps();
return refsById;
}
@@ -2630,7 +2629,7 @@ public class ReceiveCommits {
if (!(parsedObject instanceof RevCommit)) {
return;
}
SetMultimap<ObjectId, Ref> existing = changeRefsById();
ListMultimap<ObjectId, Ref> existing = changeRefsById();
walk.markStart((RevCommit)parsedObject);
markHeadsAsUninteresting(walk, cmd.getRefName());
int i = 0;
@@ -2727,7 +2726,7 @@ public class ReceiveCommits {
rw.markUninteresting(rw.parseCommit(cmd.getOldId()));
}
SetMultimap<ObjectId, Ref> byCommit = changeRefsById();
ListMultimap<ObjectId, Ref> byCommit = changeRefsById();
Map<Change.Key, ChangeNotes> byKey = null;
List<ReplaceRequest> replaceAndClose = new ArrayList<>();

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.git;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.gerrit.common.data.SubscribeSection;
@@ -115,7 +114,7 @@ public class SubmoduleOp {
// sorted version of affectedBranches
private final ImmutableSet<Branch.NameKey> sortedBranches;
// map of superproject branch and its submodule subscriptions
private final Multimap<Branch.NameKey, SubmoduleSubscription> targets;
private final SetMultimap<Branch.NameKey, SubmoduleSubscription> targets;
// map of superproject and its branches which has submodule subscriptions
private final SetMultimap<Project.NameKey, Branch.NameKey> branchesByProject;

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -99,7 +99,7 @@ public abstract class SubmitStrategy {
Set<RevCommit> alreadyAccepted,
RequestId submissionId,
NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify,
ListMultimap<RecipientType, Account.Id> accountsToNotify,
SubmoduleOp submoduleOp,
boolean dryrun);
}
@@ -133,7 +133,7 @@ public abstract class SubmitStrategy {
final RequestId submissionId;
final SubmitType submitType;
final NotifyHandling notifyHandling;
final Multimap<RecipientType, Account.Id> accountsToNotify;
final ListMultimap<RecipientType, Account.Id> accountsToNotify;
final SubmoduleOp submoduleOp;
final ProjectState project;
@@ -172,7 +172,7 @@ public abstract class SubmitStrategy {
@Assisted RequestId submissionId,
@Assisted SubmitType submitType,
@Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify,
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify,
@Assisted SubmoduleOp submoduleOp,
@Assisted boolean dryrun) {
this.accountCache = accountCache;

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.git.strategy;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.extensions.client.SubmitType;
@@ -59,7 +59,7 @@ public class SubmitStrategyFactory {
Branch.NameKey destBranch, IdentifiedUser caller, MergeTip mergeTip,
CommitStatus commits, RequestId submissionId,
NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify,
ListMultimap<RecipientType, Account.Id> accountsToNotify,
SubmoduleOp submoduleOp, boolean dryrun) throws IntegrationException {
SubmitStrategy.Arguments args = argsFactory.create(submitType, destBranch,
commits, rw, caller, mergeTip, inserter, repo, canMergeFlag, db,

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.group;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.data.GroupReference;
@@ -70,7 +70,7 @@ public class GroupsCollection implements
}
@Override
public void setParams(Multimap<String, String> params)
public void setParams(ListMultimap<String, String> params)
throws BadRequestException {
if (params.containsKey("query") && params.containsKey("query2")) {
throw new BadRequestException(

View File

@@ -23,8 +23,8 @@ import static org.eclipse.jgit.lib.RefDatabase.ALL;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ListenableFuture;
@@ -217,7 +217,7 @@ public class AllChangesIndexer
return new Callable<Void>() {
@Override
public Void call() throws Exception {
Multimap<ObjectId, ChangeData> byId =
ListMultimap<ObjectId, ChangeData> byId =
MultimapBuilder.hashKeys().arrayListValues().build();
// TODO(dborowitz): Opening all repositories in a live server may be
// wasteful; see if we can determine which ones it is safe to close
@@ -260,7 +260,7 @@ public class AllChangesIndexer
private final ChangeIndexer indexer;
private final ThreeWayMergeStrategy mergeStrategy;
private final AutoMerger autoMerger;
private final Multimap<ObjectId, ChangeData> byId;
private final ListMultimap<ObjectId, ChangeData> byId;
private final ProgressMonitor done;
private final ProgressMonitor failed;
private final PrintWriter verboseWriter;
@@ -269,7 +269,7 @@ public class AllChangesIndexer
private ProjectIndexer(ChangeIndexer indexer,
ThreeWayMergeStrategy mergeStrategy,
AutoMerger autoMerger,
Multimap<ObjectId, ChangeData> changesByCommitId,
ListMultimap<ObjectId, ChangeData> changesByCommitId,
Repository repo,
ProgressMonitor done,
ProgressMonitor failed,

View File

@@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
@@ -110,7 +109,7 @@ public class StalenessChecker {
Change indexChange,
@Nullable Change reviewDbChange,
SetMultimap<Project.NameKey, RefState> states,
Multimap<Project.NameKey, RefStatePattern> patterns) {
ListMultimap<Project.NameKey, RefStatePattern> patterns) {
return reviewDbChangeIsStale(indexChange, reviewDbChange)
|| refsAreStale(repoManager, id, states, patterns);
}
@@ -119,7 +118,7 @@ public class StalenessChecker {
static boolean refsAreStale(GitRepositoryManager repoManager,
Change.Id id,
SetMultimap<Project.NameKey, RefState> states,
Multimap<Project.NameKey, RefStatePattern> patterns) {
ListMultimap<Project.NameKey, RefStatePattern> patterns) {
Set<Project.NameKey> projects =
Sets.union(states.keySet(), patterns.keySet());
@@ -172,7 +171,7 @@ public class StalenessChecker {
return result;
}
private Multimap<Project.NameKey, RefStatePattern> parsePatterns(
private ListMultimap<Project.NameKey, RefStatePattern> parsePatterns(
ChangeData cd) {
return parsePatterns(cd.getRefStatePatterns());
}
@@ -197,7 +196,7 @@ public class StalenessChecker {
private static boolean refsAreStale(GitRepositoryManager repoManager,
Change.Id id, Project.NameKey project,
SetMultimap<Project.NameKey, RefState> allStates,
Multimap<Project.NameKey, RefStatePattern> allPatterns) {
ListMultimap<Project.NameKey, RefStatePattern> allPatterns) {
try (Repository repo = repoManager.openRepository(project)) {
Set<RefState> states = allStates.get(project);
for (RefState state : states) {

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.mail.send;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -310,7 +310,7 @@ public abstract class ChangeEmail extends NotificationEmail {
// BCC anyone who has starred this change
// and remove anyone who has ignored this change.
//
Multimap<Account.Id, String> stars =
ListMultimap<Account.Id, String> stars =
args.starredChangesUtil.byChangeFromIndex(change.getId());
for (Map.Entry<Account.Id, Collection<String>> e :
stars.asMap().entrySet()) {

View File

@@ -20,7 +20,7 @@ import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailSt
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -76,7 +76,7 @@ public abstract class OutgoingEmail {
private Address smtpFromAddress;
private StringBuilder textBody;
private StringBuilder htmlBody;
private Multimap<RecipientType, Account.Id> accountsToNotify =
private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of();
protected VelocityContext velocityContext;
protected Map<String, Object> soyContext;
@@ -101,7 +101,7 @@ public abstract class OutgoingEmail {
}
public void setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) {
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify);
}

View File

@@ -37,9 +37,9 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
@@ -562,7 +562,7 @@ public class ChangeBundle {
// but easy to reason about.
List<ChangeMessage> as = new LinkedList<>(bundleA.filterChangeMessages());
Multimap<ChangeMessageCandidate, ChangeMessage> bs =
ListMultimap<ChangeMessageCandidate, ChangeMessage> bs =
LinkedListMultimap.create();
for (ChangeMessage b : bundleB.filterChangeMessages()) {
bs.put(ChangeMessageCandidate.create(b), b);

View File

@@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.primitives.Ints;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
@@ -525,7 +525,7 @@ public class ChangeNoteUtil {
* side.
* @param out output stream to write to.
*/
void buildNote(Multimap<Integer, Comment> comments,
void buildNote(ListMultimap<Integer, Comment> comments,
OutputStream out) {
if (comments.isEmpty()) {
return;

View File

@@ -40,8 +40,8 @@ import com.google.common.base.Splitter;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.common.collect.Table;
@@ -130,7 +130,7 @@ class ChangeNotesParser {
private final List<Account.Id> allPastReviewers;
private final List<ReviewerStatusUpdate> reviewerUpdates;
private final List<SubmitRecord> submitRecords;
private final Multimap<RevId, Comment> comments;
private final ListMultimap<RevId, Comment> comments;
private final Map<PatchSet.Id, PatchSet> patchSets;
private final Set<PatchSet.Id> deletedPatchSets;
private final Map<PatchSet.Id, PatchSetState> patchSetStates;
@@ -138,7 +138,8 @@ class ChangeNotesParser {
private final Map<ApprovalKey, PatchSetApproval> approvals;
private final List<PatchSetApproval> bufferedApprovals;
private final List<ChangeMessage> allChangeMessages;
private final Multimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet;
private final ListMultimap<PatchSet.Id, ChangeMessage>
changeMessagesByPatchSet;
// Non-final private members filled in during the parsing process.
private String branch;
@@ -248,8 +249,8 @@ class ChangeNotesParser {
return null;
}
private Multimap<PatchSet.Id, PatchSetApproval> buildApprovals() {
Multimap<PatchSet.Id, PatchSetApproval> result =
private ListMultimap<PatchSet.Id, PatchSetApproval> buildApprovals() {
ListMultimap<PatchSet.Id, PatchSetApproval> result =
MultimapBuilder.hashKeys().arrayListValues().build();
for (PatchSetApproval a : approvals.values()) {
if (!patchSets.containsKey(a.getPatchSetId())) {
@@ -283,7 +284,7 @@ class ChangeNotesParser {
return Lists.reverse(allChangeMessages);
}
private Multimap<PatchSet.Id, ChangeMessage> buildMessagesByPatchSet() {
private ListMultimap<PatchSet.Id, ChangeMessage> buildMessagesByPatchSet() {
for (Collection<ChangeMessage> v :
changeMessagesByPatchSet.asMap().values()) {
Collections.reverse((List<ChangeMessage>) v);

View File

@@ -22,7 +22,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Account;
@@ -95,14 +95,14 @@ public abstract class ChangeNotesState {
@Nullable Set<Account.Id> pastAssignees,
@Nullable Set<String> hashtags,
Map<PatchSet.Id, PatchSet> patchSets,
Multimap<PatchSet.Id, PatchSetApproval> approvals,
ListMultimap<PatchSet.Id, PatchSetApproval> approvals,
ReviewerSet reviewers,
List<Account.Id> allPastReviewers,
List<ReviewerStatusUpdate> reviewerUpdates,
List<SubmitRecord> submitRecords,
List<ChangeMessage> allChangeMessages,
Multimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet,
Multimap<RevId, Comment> publishedComments) {
ListMultimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet,
ListMultimap<RevId, Comment> publishedComments) {
if (hashtags == null) {
hashtags = ImmutableSet.of();
}

View File

@@ -21,7 +21,7 @@ import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.metrics.Timer1;
@@ -167,7 +167,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
revisionNoteMap = RevisionNoteMap.parse(
args.noteUtil, getChangeId(), reader, NoteMap.read(reader, tipCommit),
PatchLineComment.Status.DRAFT);
Multimap<RevId, Comment> cs =
ListMultimap<RevId, Comment> cs =
MultimapBuilder.hashKeys().arrayListValues().build();
for (ChangeRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
for (Comment c : rn.getComments()) {

View File

@@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Comment;
import com.google.gerrit.reviewdb.client.RevId;
@@ -112,8 +112,8 @@ class RevisionNoteBuilder {
this.pushCert = pushCert;
}
private Multimap<Integer, Comment> buildCommentMap() {
Multimap<Integer, Comment> all =
private ListMultimap<Integer, Comment> buildCommentMap() {
ListMultimap<Integer, Comment> all =
MultimapBuilder.hashKeys().arrayListValues().build();
for (Comment c : baseComments) {
@@ -131,7 +131,7 @@ class RevisionNoteBuilder {
private void buildNoteJson(ChangeNoteUtil noteUtil, OutputStream out)
throws IOException {
Multimap<Integer, Comment> comments = buildCommentMap();
ListMultimap<Integer, Comment> comments = buildCommentMap();
if (comments.isEmpty() && pushCert == null) {
return;
}

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.notedb;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Change;
@@ -95,7 +95,7 @@ public class RobotCommentNotes extends AbstractChangeNotes<RobotCommentNotes> {
ObjectReader reader = handle.walk().getObjectReader();
revisionNoteMap = RevisionNoteMap.parseRobotComments(args.noteUtil, reader,
NoteMap.read(reader, tipCommit));
Multimap<RevId, RobotComment> cs =
ListMultimap<RevId, RobotComment> cs =
MultimapBuilder.hashKeys().arrayListValues().build();
for (RobotCommentsRevisionNote rn :
revisionNoteMap.revisionNotes.values()) {

View File

@@ -25,9 +25,9 @@ import static java.util.stream.Collectors.toList;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
@@ -299,7 +299,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
// We will rebuild all events, except for draft comments, in buckets based
// on author and timestamp.
List<Event> events = new ArrayList<>();
Multimap<Account.Id, DraftCommentEvent> draftCommentEvents =
ListMultimap<Account.Id, DraftCommentEvent> draftCommentEvents =
MultimapBuilder.hashKeys().arrayListValues().build();
events.addAll(getHashtagsEvents(change, manager));

View File

@@ -19,7 +19,7 @@ import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnn
import static com.google.gerrit.server.plugins.PluginGuiceEnvironment.is;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.annotations.Listen;
@@ -54,7 +54,7 @@ class AutoRegisterModules {
private final ModuleGenerator httpGen;
private Set<Class<?>> sysSingletons;
private Multimap<TypeLiteral<?>, Class<?>> sysListen;
private ListMultimap<TypeLiteral<?>, Class<?>> sysListen;
private String initJs;
Module sysModule;

View File

@@ -19,9 +19,9 @@ import static com.google.common.collect.Iterables.transform;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import org.eclipse.jgit.util.IO;
@@ -67,7 +67,7 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
String pluginName, Iterable<Class<? extends Annotation>> annotations)
throws InvalidPluginException {
Set<String> descriptors = new HashSet<>();
Multimap<String, JarScanner.ClassData> rawMap =
ListMultimap<String, JarScanner.ClassData> rawMap =
MultimapBuilder.hashKeys().arrayListValues().build();
Map<Class<? extends Annotation>, String> classObjToClassDescr =
new HashMap<>();

View File

@@ -24,8 +24,8 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -399,7 +399,7 @@ public class PluginLoader implements LifecycleListener {
}
public synchronized void rescan() {
Multimap<String, Path> pluginsFiles = prunePlugins(pluginsDir);
SetMultimap<String, Path> pluginsFiles = prunePlugins(pluginsDir);
if (pluginsFiles.isEmpty()) {
return;
}
@@ -478,7 +478,7 @@ public class PluginLoader implements LifecycleListener {
return sortedPlugins;
}
private void syncDisabledPlugins(Multimap<String, Path> jars) {
private void syncDisabledPlugins(SetMultimap<String, Path> jars) {
stopRemovedPlugins(jars);
dropRemovedDisabledPlugins(jars);
}
@@ -525,7 +525,7 @@ public class PluginLoader implements LifecycleListener {
}
}
private void stopRemovedPlugins(Multimap<String, Path> jars) {
private void stopRemovedPlugins(SetMultimap<String, Path> jars) {
Set<String> unload = Sets.newHashSet(running.keySet());
for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) {
for (Path path : entry.getValue()) {
@@ -539,7 +539,7 @@ public class PluginLoader implements LifecycleListener {
}
}
private void dropRemovedDisabledPlugins(Multimap<String, Path> jars) {
private void dropRemovedDisabledPlugins(SetMultimap<String, Path> jars) {
Set<String> unload = Sets.newHashSet(disabled.keySet());
for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) {
for (Path path : entry.getValue()) {
@@ -644,7 +644,7 @@ public class PluginLoader implements LifecycleListener {
// Only one active plugin per plugin name can exist for each plugin name.
// Filter out disabled plugins and transform the multimap to a map
private static Map<String, Path> filterDisabled(
Multimap<String, Path> pluginPaths) {
SetMultimap<String, Path> pluginPaths) {
Map<String, Path> activePlugins = Maps.newHashMapWithExpectedSize(
pluginPaths.keys().size());
for (String name : pluginPaths.keys()) {
@@ -667,9 +667,9 @@ public class PluginLoader implements LifecycleListener {
//
// NOTE: Bear in mind that the plugin name can be reassigned after load by the
// Server plugin provider.
public Multimap<String, Path> prunePlugins(Path pluginsDir) {
public SetMultimap<String, Path> prunePlugins(Path pluginsDir) {
List<Path> pluginPaths = scanPathsInPluginsDirectory(pluginsDir);
Multimap<String, Path> map;
SetMultimap<String, Path> map;
map = asMultimap(pluginPaths);
for (String plugin : map.keySet()) {
Collection<Path> files = map.asMap().get(plugin);
@@ -735,8 +735,8 @@ public class PluginLoader implements LifecycleListener {
return null;
}
private Multimap<String, Path> asMultimap(List<Path> plugins) {
Multimap<String, Path> map = LinkedHashMultimap.create();
private SetMultimap<String, Path> asMultimap(List<Path> plugins) {
SetMultimap<String, Path> map = LinkedHashMultimap.create();
for (Path srcPath : plugins) {
map.put(getPluginName(srcPath), srcPath);
}

View File

@@ -18,9 +18,9 @@ import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.gerrit.server.project.RefPattern.isRE;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.AccessSection;
@@ -118,7 +118,7 @@ public class PermissionCollection {
HashMap<String, List<PermissionRule>> permissions = new HashMap<>();
HashMap<String, List<PermissionRule>> overridden = new HashMap<>();
Map<PermissionRule, ProjectRef> ruleProps = Maps.newIdentityHashMap();
Multimap<Project.NameKey, String> exclusivePermissionsByProject =
ListMultimap<Project.NameKey, String> exclusivePermissionsByProject =
MultimapBuilder.hashKeys().arrayListValues().build();
for (AccessSection section : sections) {
Project.NameKey project = sectionToProject.get(section);

View File

@@ -24,12 +24,10 @@ import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.common.data.SubmitTypeRecord;
@@ -352,7 +350,7 @@ public class ChangeData {
private Map<Account.Id, Ref> draftsByUser;
@Deprecated
private Set<Account.Id> starredByUser;
private ImmutableMultimap<Account.Id, String> stars;
private ImmutableListMultimap<Account.Id, String> stars;
private ImmutableMap<Account.Id, StarRef> starRefs;
private ReviewerSet reviewers;
private List<ReviewerStatusUpdate> reviewerUpdates;
@@ -1230,13 +1228,13 @@ public class ChangeData {
this.starredByUser = starredByUser;
}
public ImmutableMultimap<Account.Id, String> stars() throws OrmException {
public ImmutableListMultimap<Account.Id, String> stars() throws OrmException {
if (stars == null) {
if (!lazyLoad) {
return ImmutableMultimap.of();
return ImmutableListMultimap.of();
}
ImmutableMultimap.Builder<Account.Id, String> b =
ImmutableMultimap.builder();
ImmutableListMultimap.Builder<Account.Id, String> b =
ImmutableListMultimap.builder();
for (Map.Entry<Account.Id, StarRef> e : starRefs().entrySet()) {
b.putAll(e.getKey(), e.getValue().labels());
}
@@ -1245,8 +1243,8 @@ public class ChangeData {
return stars;
}
public void setStars(Multimap<Account.Id, String> stars) {
this.stars = ImmutableMultimap.copyOf(stars);
public void setStars(ListMultimap<Account.Id, String> stars) {
this.stars = ImmutableListMultimap.copyOf(stars);
}
public ImmutableMap<Account.Id, StarRef> starRefs() throws OrmException {

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.schema;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
@@ -100,9 +100,9 @@ public class Schema_108 extends SchemaVersion {
}
}
Multimap<ObjectId, Ref> changeRefsBySha =
ListMultimap<ObjectId, Ref> changeRefsBySha =
MultimapBuilder.hashKeys().arrayListValues().build();
Multimap<ObjectId, PatchSet.Id> patchSetsBySha =
ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha =
MultimapBuilder.hashKeys().arrayListValues().build();
for (Ref ref : refdb.getRefs(RefNames.REFS_CHANGES).values()) {
ObjectId id = ref.getObjectId();
@@ -132,7 +132,7 @@ public class Schema_108 extends SchemaVersion {
}
private static void updateGroups(ReviewDb db, GroupCollector collector,
Multimap<ObjectId, PatchSet.Id> patchSetsBySha) throws OrmException {
ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha) throws OrmException {
Map<PatchSet.Id, PatchSet> patchSets =
db.patchSets().toMap(db.patchSets().get(patchSetsBySha.values()));
for (Map.Entry<ObjectId, Collection<String>> e

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.schema;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
@@ -57,7 +57,7 @@ public class Schema_123 extends SchemaVersion {
@Override
protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException {
Multimap<Account.Id, Change.Id> imports =
ListMultimap<Account.Id, Change.Id> imports =
MultimapBuilder.hashKeys().arrayListValues().build();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery(

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.schema;
import static java.util.Comparator.comparing;
import com.google.common.base.Strings;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering;
import com.google.gerrit.reviewdb.client.Account;
@@ -71,7 +71,7 @@ public class Schema_124 extends SchemaVersion {
@Override
protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException {
Multimap<Account.Id, AccountSshKey> imports =
ListMultimap<Account.Id, AccountSshKey> imports =
MultimapBuilder.hashKeys().arrayListValues().build();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery(

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.schema;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Project;
@@ -73,7 +73,7 @@ public class Schema_139 extends SchemaVersion {
@Override
protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException {
Multimap<Account.Id, ProjectWatch> imports = ArrayListMultimap.create();
ListMultimap<Account.Id, ProjectWatch> imports = ArrayListMultimap.create();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT "
@@ -183,4 +183,4 @@ public class Schema_139 extends SchemaVersion {
abstract ProjectWatch build();
}
}
}
}