Avoid Multimap implementation create methods

Guava team recommends MultimapBuilder over specific Multimap
implementations, so callers don't have to know the specific key/value
behaviors of the individual implementations. The static factory
methods in the implementations will be removed in a later version.

LinkedListMultimap and LinkedHashMultimap are not affected, since
MultimapBuilder lacks support for specifying linked entries, and thus
the factory methods are not in immediate danger of deletion.

Change-Id: I7744db687da84a7beae31d1cb8953e782ed23c1d
This commit is contained in:
Dave Borowitz
2017-01-13 16:45:47 -05:00
committed by David Pursehouse
parent 484da493b3
commit 0ecf8cf401
10 changed files with 30 additions and 22 deletions

View File

@@ -24,11 +24,11 @@ import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STA
import static java.util.stream.Collectors.toList;
import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -411,7 +411,7 @@ public class LuceneChangeIndex implements ChangeIndex {
private static ListMultimap<String, IndexableField> fields(Document doc,
Set<String> fields) {
ListMultimap<String, IndexableField> stored =
ArrayListMultimap.create(fields.size(), 4);
MultimapBuilder.hashKeys(fields.size()).arrayListValues(4).build();
for (IndexableField f : doc) {
String name = f.name();
if (fields.contains(name)) {
@@ -559,7 +559,8 @@ public class LuceneChangeIndex implements ChangeIndex {
private void decodeStar(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
Collection<IndexableField> star = doc.get(STAR_FIELD);
ListMultimap<Account.Id, String> stars = ArrayListMultimap.create();
ListMultimap<Account.Id, String> stars =
MultimapBuilder.hashKeys().arrayListValues().build();
for (IndexableField r : star) {
StarredChangesUtil.StarField starField =
StarredChangesUtil.StarField.parse(r.stringValue());