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:
committed by
David Pursehouse
parent
e5c5953205
commit
484da493b3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user