Use native constructors instead of Guava to instantiate empty collections

It's not necessary to use Guava's helper methods when instantiating
empty collections. Just use the native constructors.

Change-Id: I7f454909b15924ee49e149edf9f053da9f718502
This commit is contained in:
David Pursehouse
2016-05-03 23:16:15 +09:00
parent b621cb9eb7
commit ccdeae8e64
135 changed files with 394 additions and 383 deletions

View File

@@ -1804,7 +1804,7 @@ public class MyMenu implements TopMenu {
@Inject
public MyMenu(@PluginName String name) {
menuEntries = Lists.newArrayList();
menuEntries = new ArrayList<>();
menuEntries.add(new MenuEntry("My Menu", Collections.singletonList(
new MenuItem("My Screen", "#/x/" + name + "/my-screen", ""))));
}

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.acceptance;
import com.google.common.collect.Maps;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
@@ -32,6 +31,7 @@ import com.google.inject.Provider;
import com.google.inject.Scope;
import com.google.inject.util.Providers;
import java.util.HashMap;
import java.util.Map;
/** Guice scopes for state during an Acceptance Test connection. */
@@ -44,7 +44,7 @@ public class AcceptanceTestRequestScope {
public static class Context implements RequestContext {
private final RequestCleanup cleanup = new RequestCleanup();
private final Map<Key<?>, Object> map = Maps.newHashMap();
private final Map<Key<?>, Object> map = new HashMap<>();
private final SchemaFactory<ReviewDb> schemaFactory;
private final SshSession session;
private final CurrentUser user;

View File

@@ -21,7 +21,6 @@ import static com.google.gerrit.acceptance.rest.account.AccountAssert.assertAcco
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
@@ -49,6 +48,7 @@ import org.junit.Test;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -125,7 +125,7 @@ public class GroupsIT extends AbstractDaemonTest {
String p = createGroup("parent");
String g1 = createGroup("newGroup1");
String g2 = createGroup("newGroup2");
List<String> groups = Lists.newLinkedList();
List<String> groups = new LinkedList<>();
groups.add(g1);
groups.add(g2);
gApi.groups().id(p).addGroups(g1, g2);

View File

@@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -82,6 +81,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -127,7 +127,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
@Before
public void setUp() throws Exception {
mergeResults = Maps.newHashMap();
mergeResults = new HashMap<>();
eventListenerRegistration =
eventListeners.add(new UserScopedEventListener() {
@Override

View File

@@ -20,7 +20,6 @@ import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVI
import static com.google.gerrit.extensions.client.ListChangesOption.MESSAGES;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -29,6 +28,7 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@NoHttpd
@@ -39,7 +39,7 @@ public class ListChangesOptionsIT extends AbstractDaemonTest {
@Before
public void setUp() throws Exception {
results = Lists.newArrayList();
results = new ArrayList<>();
results.add(push("file contents", null));
changeId = results.get(0).getChangeId();
results.add(push("new contents 1", changeId));

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.cache.h2;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.extensions.registration.DynamicMap;
@@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
@@ -70,7 +70,7 @@ class H2CacheFactory implements PersistentCacheFactory, LifecycleListener {
config = cfg;
cacheDir = getCacheDir(site, cfg.getString("cache", null, "directory"));
h2CacheSize = cfg.getLong("cache", null, "h2CacheSize", -1);
caches = Lists.newLinkedList();
caches = new LinkedList<>();
this.cacheMap = cacheMap;
if (cacheDir != null) {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.httpd.plugins;
import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnnotation;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.server.plugins.InvalidPluginException;
@@ -28,13 +27,14 @@ import com.google.inject.TypeLiteral;
import com.google.inject.servlet.ServletModule;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServlet;
class HttpAutoRegisterModuleGenerator extends ServletModule
implements ModuleGenerator {
private final Map<String, Class<HttpServlet>> serve = Maps.newHashMap();
private final Map<String, Class<HttpServlet>> serve = new HashMap<>();
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create();
@Override

View File

@@ -66,8 +66,10 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
@@ -100,7 +102,7 @@ class HttpPluginServlet extends HttpServlet
private final int sshPort;
private final RestApiServlet managerApi;
private List<Plugin> pending = Lists.newArrayList();
private List<Plugin> pending = new ArrayList<>();
private ContextMapper wrapper;
private final ConcurrentMap<String, PluginHolder> plugins
= Maps.newConcurrentMap();
@@ -370,10 +372,10 @@ class HttpPluginServlet extends HttpServlet
String prefix, String pluginName,
PluginResourceKey cacheKey, HttpServletResponse res,long lastModifiedTime)
throws IOException {
List<PluginEntry> cmds = Lists.newArrayList();
List<PluginEntry> servlets = Lists.newArrayList();
List<PluginEntry> restApis = Lists.newArrayList();
List<PluginEntry> docs = Lists.newArrayList();
List<PluginEntry> cmds = new ArrayList<>();
List<PluginEntry> servlets = new ArrayList<>();
List<PluginEntry> restApis = new ArrayList<>();
List<PluginEntry> docs = new ArrayList<>();
PluginEntry about = null;
Enumeration<PluginEntry> entries = scanner.entries();
while (entries.hasMoreElements()) {
@@ -443,7 +445,7 @@ class HttpPluginServlet extends HttpServlet
private void sendMarkdownAsHtml(String md, String pluginName,
PluginResourceKey cacheKey, HttpServletResponse res, long lastModifiedTime)
throws UnsupportedEncodingException, IOException {
Map<String, String> macros = Maps.newHashMap();
Map<String, String> macros = new HashMap<>();
macros.put("PLUGIN", pluginName);
macros.put("SSH_HOST", sshHost);
macros.put("SSH_PORT", "" + sshPort);

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.httpd.plugins;
import static javax.servlet.http.HttpServletResponse.SC_NOT_IMPLEMENTED;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.httpd.resources.Resource;
import com.google.gerrit.server.config.GerritServerConfig;
@@ -33,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.FilterChain;
@@ -55,7 +55,7 @@ public class LfsPluginServlet extends HttpServlet
public static final String URL_REGEX =
"^(?:/a)?(?:/p/|/)(.+)(?:/info/lfs/objects/batch)$";
private List<Plugin> pending = Lists.newArrayList();
private List<Plugin> pending = new ArrayList<>();
private final String pluginName;
private GuiceFilter filter;

View File

@@ -18,7 +18,6 @@ import static com.google.gerrit.common.FileUtil.lastModified;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.common.primitives.Bytes;
@@ -231,7 +230,7 @@ public class HostPageServlet extends HttpServlet {
}
private void plugins(StringWriter w) {
List<String> urls = Lists.newArrayList();
List<String> urls = new ArrayList<>();
for (WebUiPlugin u : plugins) {
urls.add(String.format("plugins/%s/%s",
u.getPluginName(),

View File

@@ -24,7 +24,6 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.Url;
@@ -40,6 +39,7 @@ import org.kohsuke.args4j.CmdLineException;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -107,7 +107,7 @@ class ParameterParser {
}
private static Set<String> query(HttpServletRequest req) {
Set<String> params = Sets.newHashSet();
Set<String> params = new HashSet<>();
if (!Strings.isNullOrEmpty(req.getQueryString())) {
for (String kvPair : Splitter.on('&').split(req.getQueryString())) {
params.add(Iterables.getFirst(

View File

@@ -40,9 +40,7 @@ import com.google.common.collect.ImmutableMultimap;
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.Sets;
import com.google.common.io.BaseEncoding;
import com.google.common.io.CountingOutputStream;
import com.google.common.math.IntMath;
@@ -123,10 +121,14 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;
@@ -712,13 +714,13 @@ public class RestApiServlet extends HttpServlet {
private static void enablePartialGetFields(GsonBuilder gb,
Multimap<String, String> config) {
final Set<String> want = Sets.newHashSet();
final Set<String> want = new HashSet<>();
for (String p : config.get("fields")) {
Iterables.addAll(want, OptionUtil.splitOptionValue(p));
}
if (!want.isEmpty()) {
gb.addSerializationExclusionStrategy(new ExclusionStrategy() {
private final Map<String, String> names = Maps.newHashMap();
private final Map<String, String> names = new HashMap<>();
@Override
public boolean shouldSkipField(FieldAttributes field) {
@@ -917,7 +919,7 @@ public class RestApiServlet extends HttpServlet {
}
}
Map<String, RestView<RestResource>> r = Maps.newTreeMap();
Map<String, RestView<RestResource>> r = new TreeMap<>();
for (String plugin : views.plugins()) {
RestView<RestResource> action = views.get(plugin, name);
if (action != null) {
@@ -950,7 +952,7 @@ public class RestApiServlet extends HttpServlet {
if (Strings.isNullOrEmpty(path)) {
return Collections.emptyList();
}
List<IdString> out = Lists.newArrayList();
List<IdString> out = new ArrayList<>();
for (String p : Splitter.on('/').split(path)) {
out.add(IdString.fromUrl(p));
}

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.httpd.rpc.account;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.AgreementInfo;
import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gerrit.common.data.PermissionRule;
@@ -29,7 +27,9 @@ import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,14 +54,14 @@ class AgreementInfoFactory extends Handler<AgreementInfo> {
@Override
public AgreementInfo call() throws Exception {
List<String> accepted = Lists.newArrayList();
Map<String, ContributorAgreement> agreements = Maps.newHashMap();
List<String> accepted = new ArrayList<>();
Map<String, ContributorAgreement> agreements = new HashMap<>();
Collection<ContributorAgreement> cas =
projectCache.getAllProjects().getConfig().getContributorAgreements();
for (ContributorAgreement ca : cas) {
agreements.put(ca.getName(), ca.forUi());
List<AccountGroup.UUID> groupIds = Lists.newArrayList();
List<AccountGroup.UUID> groupIds = new ArrayList<>();
for (PermissionRule rule : ca.getAccepted()) {
if ((rule.getAction() == Action.ALLOW) && (rule.getGroup() != null)) {
if (rule.getGroup().getUUID() == null) {

View File

@@ -226,7 +226,7 @@ public class LuceneVersionManager implements LifecycleListener {
private <K, V, I extends Index<K, V>> TreeMap<Integer, Version<V>>
scanVersions(IndexDefinition<K, V, I> def, GerritIndexStatus cfg) {
TreeMap<Integer, Version<V>> versions = Maps.newTreeMap();
TreeMap<Integer, Version<V>> versions = new TreeMap<>();
for (Schema<V> schema : def.getSchemas().values()) {
// This part is Lucene-specific.
Path p = getDir(sitePaths, def.getName(), schema);

View File

@@ -20,7 +20,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.auth.openid.OpenIdUrls;
@@ -46,6 +45,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -102,7 +102,7 @@ class LoginForm extends HttpServlet {
suggestProviders = ImmutableSet.of();
ssoUrl = authConfig.getOpenIdSsoUrl();
} else {
Set<String> providers = Sets.newHashSet();
Set<String> providers = new HashSet<>();
for (Map.Entry<String, String> e : ALL_PROVIDERS.entrySet()) {
if (impl.isAllowedOpenID(e.getValue())) {
providers.add(e.getKey());

View File

@@ -123,7 +123,7 @@ public class Init extends BaseInit {
@Override
protected void afterInit(SiteRun run) throws Exception {
List<Module> modules = Lists.newArrayList();
List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.pgm;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
import com.google.common.collect.Lists;
import com.google.gerrit.common.Die;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.lucene.LuceneIndexModule;
@@ -42,6 +41,7 @@ import org.eclipse.jgit.util.io.NullOutputStream;
import org.kohsuke.args4j.Option;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -114,7 +114,7 @@ public class Reindex extends SiteProgram {
if (changesVersion != null) {
versions.put(ChangeSchemaDefinitions.INSTANCE.getName(), changesVersion);
}
List<Module> modules = Lists.newArrayList();
List<Module> modules = new ArrayList<>();
Module indexModule;
switch (IndexModule.getIndexType(dbInjector)) {
case LUCENE:

View File

@@ -20,7 +20,6 @@ import static com.google.inject.Stage.PRODUCTION;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.gerrit.common.Die;
import com.google.gerrit.common.IoUtil;
import com.google.gerrit.pgm.init.api.ConsoleUI;
@@ -247,7 +246,7 @@ public class BaseInit extends SiteProgram {
bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
List<String> plugins =
MoreObjects.firstNonNull(
getInstallPlugins(), Lists.<String> newArrayList());
getInstallPlugins(), new ArrayList<String>());
bind(new TypeLiteral<List<String>>() {}).annotatedWith(
InstallPlugins.class).toInstance(plugins);
bind(new TypeLiteral<Boolean>() {}).annotatedWith(

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.pgm.init;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists;
import com.google.gerrit.common.PluginData;
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitFlags;
@@ -30,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
@@ -55,7 +55,7 @@ public class InitPlugins implements InitStep {
private static List<PluginData> listPlugins(final SitePaths site,
final boolean deleteTempPluginFile, PluginsDistribution pluginsDistribution)
throws IOException {
final List<PluginData> result = Lists.newArrayList();
final List<PluginData> result = new ArrayList<>();
pluginsDistribution.foreach(new PluginsDistribution.Processor() {
@Override
public void process(String pluginName, InputStream in) throws IOException {

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.pgm.util;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -24,6 +23,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.ProvisionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -43,7 +43,7 @@ class PerThreadReviewDbModule extends LifecycleModule {
@Override
protected void configure() {
final List<ReviewDb> dbs = Collections.synchronizedList(
Lists.<ReviewDb> newArrayList());
new ArrayList<ReviewDb>());
final ThreadLocal<ReviewDb> localDb = new ThreadLocal<>();
bind(ReviewDb.class).toProvider(new Provider<ReviewDb>() {

View File

@@ -18,7 +18,6 @@ import static com.google.gerrit.server.config.GerritServerConfigModule.getSecure
import static com.google.inject.Scopes.SINGLETON;
import static com.google.inject.Stage.PRODUCTION;
import com.google.common.collect.Lists;
import com.google.gerrit.common.Die;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
@@ -224,7 +223,7 @@ public abstract class SiteProgram extends AbstractProgram {
throw new RuntimeException(e);
}
List<Module> modules = Lists.newArrayList();
List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {

View File

@@ -18,7 +18,6 @@ import static com.googlecode.prolog_cafe.lang.PrologMachineCopy.save;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
@@ -61,6 +60,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@@ -283,7 +283,7 @@ public class RulesCache {
predicateProviders, cl)));
ctl.setEnabled(EnumSet.allOf(Prolog.Feature.class), false);
List<String> packages = Lists.newArrayList();
List<String> packages = new ArrayList<>();
packages.addAll(PACKAGE_LIST);
for (PredicateProvider predicateProvider : predicateProviders) {
packages.addAll(predicateProvider.getPackages());

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.rules;
import static com.google.gerrit.rules.StoredValue.create;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
@@ -45,6 +44,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public final class StoredValues {
@@ -150,7 +150,7 @@ public final class StoredValues {
new StoredValue<Map<Account.Id, IdentifiedUser>>() {
@Override
protected Map<Account.Id, IdentifiedUser> createValue(Prolog engine) {
return Maps.newHashMap();
return new HashMap<>();
}
};

View File

@@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Table;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.reviewdb.client.Account;
@@ -148,7 +147,7 @@ public class ApprovalCopier {
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd)
throws OrmException {
Collection<PatchSet> patchSets = cd.patchSets();
TreeMap<Integer, PatchSet> result = Maps.newTreeMap();
TreeMap<Integer, PatchSet> result = new TreeMap<>();
for (PatchSet ps : patchSets) {
result.put(ps.getId().get(), ps);
}

View File

@@ -152,7 +152,7 @@ public class PatchLineCommentsUtil {
}
notes.load();
List<PatchLineComment> comments = Lists.newArrayList();
List<PatchLineComment> comments = new ArrayList<>();
comments.addAll(notes.getComments().values());
return sort(comments);
}
@@ -164,7 +164,7 @@ public class PatchLineCommentsUtil {
db.patchComments().byChange(notes.getChangeId()), Status.DRAFT));
}
List<PatchLineComment> comments = Lists.newArrayList();
List<PatchLineComment> comments = new ArrayList<>();
for (Ref ref : getDraftRefs(notes.getChangeId())) {
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
if (account != null) {
@@ -192,7 +192,7 @@ public class PatchLineCommentsUtil {
if (!migration.readChanges()) {
return sort(db.patchComments().byPatchSet(psId).toList());
}
List<PatchLineComment> comments = Lists.newArrayList();
List<PatchLineComment> comments = new ArrayList<>();
comments.addAll(publishedByPatchSet(db, notes, psId));
for (Ref ref : getDraftRefs(notes.getChangeId())) {
@@ -262,7 +262,7 @@ public class PatchLineCommentsUtil {
}
}).toSortedList(PLC_ORDER);
}
List<PatchLineComment> comments = Lists.newArrayList();
List<PatchLineComment> comments = new ArrayList<>();
comments.addAll(notes.getDraftComments(author).values());
return sort(comments);
}
@@ -274,7 +274,7 @@ public class PatchLineCommentsUtil {
return sort(db.patchComments().draftByAuthor(author).toList());
}
List<PatchLineComment> comments = Lists.newArrayList();
List<PatchLineComment> comments = new ArrayList<>();
try (Repository repo = repoManager.openRepository(allUsers)) {
for (String refName : repo.getRefDatabase()
.getRefs(RefNames.REFS_DRAFT_COMMENTS).keySet()) {

View File

@@ -129,7 +129,7 @@ public class ReviewersUtil {
suggestedAccounts = suggestAccount(suggestReviewers, visibilityControl);
}
List<SuggestedReviewerInfo> reviewer = Lists.newArrayList();
List<SuggestedReviewerInfo> reviewer = new ArrayList<>();
for (AccountInfo a : suggestedAccounts) {
SuggestedReviewerInfo info = new SuggestedReviewerInfo();
info.account = a;

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.server.access;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.api.access.ProjectAccessInfo;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -28,14 +26,16 @@ import com.google.inject.Inject;
import org.kohsuke.args4j.Option;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class ListAccess implements RestReadView<TopLevelResource> {
@Option(name = "--project", aliases = {"-p"}, metaVar = "PROJECT",
usage = "projects for which the access rights should be returned")
private List<String> projects = Lists.newArrayList();
private List<String> projects = new ArrayList<>();
private final GetAccess getAccess;
@@ -47,7 +47,7 @@ public class ListAccess implements RestReadView<TopLevelResource> {
@Override
public Map<String, ProjectAccessInfo> apply(TopLevelResource resource)
throws ResourceNotFoundException, ResourceConflictException, IOException {
Map<String, ProjectAccessInfo> access = Maps.newTreeMap();
Map<String, ProjectAccessInfo> access = new TreeMap<>();
for (String p : projects) {
Project.NameKey projectName = new Project.NameKey(p);
access.put(p, getAccess.apply(projectName));

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.account;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountExternalId;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -33,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@@ -93,7 +93,7 @@ public class AccountByEmailCacheImpl implements AccountByEmailCache {
@Override
public Set<Account.Id> load(String email) throws Exception {
try (ReviewDb db = schema.open()) {
Set<Account.Id> r = Sets.newHashSet();
Set<Account.Id> r = new HashSet<>();
for (Account a : db.accounts().byPreferredEmail(email)) {
r.add(a.getId());
}

View File

@@ -18,8 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.account.AccountDirectory.DirectoryException;
@@ -28,9 +26,11 @@ import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,8 +57,8 @@ public class AccountLoader {
AccountLoader(InternalAccountDirectory directory, @Assisted boolean detailed) {
this.directory = directory;
options = detailed ? DETAILED_OPTIONS : InternalAccountDirectory.ID_ONLY;
created = Maps.newHashMap();
provided = Lists.newArrayList();
created = new HashMap<>();
provided = new ArrayList<>();
}
public AccountInfo get(Account.Id id) {

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.account;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountExternalId;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -154,7 +153,7 @@ public class AccountResolver {
// more than one match, try to return the best one
String name = nameOrEmail.substring(0, lt - 1);
Set<Account.Id> nameMatches = Sets.newHashSet();
Set<Account.Id> nameMatches = new HashSet<>();
for (Account.Id id : ids) {
Account a = byId.get(id).getAccount();
if (name.equals(a.getFullName())) {

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.account;
import com.google.common.collect.Sets;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.GlobalCapability;
@@ -51,6 +50,7 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -214,7 +214,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, Input> {
private Set<AccountGroup.Id> parseGroups(List<String> groups)
throws UnprocessableEntityException {
Set<AccountGroup.Id> groupIds = Sets.newHashSet();
Set<AccountGroup.Id> groupIds = new HashSet<>();
if (groups != null) {
for (String g : groups) {
groupIds.add(GroupDescriptions.toAccountGroup(

View File

@@ -33,8 +33,6 @@ import static com.google.gerrit.common.data.GlobalCapability.VIEW_PLUGINS;
import static com.google.gerrit.common.data.GlobalCapability.VIEW_QUEUE;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.extensions.config.CapabilityDefinition;
@@ -54,7 +52,9 @@ import com.google.inject.Singleton;
import org.kohsuke.args4j.Option;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@@ -62,7 +62,7 @@ class GetCapabilities implements RestReadView<AccountResource> {
@Option(name = "-q", metaVar = "CAP", usage = "Capability to inspect")
void addQuery(String name) {
if (query == null) {
query = Sets.newHashSet();
query = new HashSet<>();
}
Iterables.addAll(query, OptionUtil.splitOptionValue(name));
}
@@ -86,7 +86,7 @@ class GetCapabilities implements RestReadView<AccountResource> {
}
CapabilityControl cc = resource.getUser().getCapabilities();
Map<String, Object> have = Maps.newLinkedHashMap();
Map<String, Object> have = new LinkedHashMap<>();
for (String name : GlobalCapability.getAllNames()) {
if (!name.equals(PRIORITY) && want(name) && cc.canPerform(name)) {
if (GlobalCapability.hasRange(name)) {

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.server.account;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -27,7 +27,7 @@ public class GetEmails implements RestReadView<AccountResource> {
@Override
public List<EmailInfo> apply(AccountResource rsrc) {
List<EmailInfo> emails = Lists.newArrayList();
List<EmailInfo> emails = new ArrayList<>();
for (String email : rsrc.getUser().getEmailAddresses()) {
if (email != null) {
EmailInfo e = new EmailInfo();

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.account;
import com.google.common.collect.Lists;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.restapi.RestReadView;
@@ -26,6 +25,7 @@ import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
@Singleton
@@ -43,7 +43,7 @@ public class GetGroups implements RestReadView<AccountResource> {
public List<GroupInfo> apply(AccountResource resource) throws OrmException {
IdentifiedUser user = resource.getUser();
Account.Id userId = user.getAccountId();
List<GroupInfo> groups = Lists.newArrayList();
List<GroupInfo> groups = new ArrayList<>();
for (AccountGroup.UUID uuid : user.getEffectiveGroups().getKnownGroups()) {
GroupControl ctl;
try {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.account;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.AccountGroupById;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -33,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@@ -150,7 +150,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
return Collections.emptySet();
}
Set<AccountGroup.UUID> ids = Sets.newHashSet();
Set<AccountGroup.UUID> ids = new HashSet<>();
for (AccountGroupById agi : db.accountGroupById()
.byGroup(group.get(0).getId())) {
ids.add(agi.getIncludeUUID());
@@ -172,13 +172,13 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public Set<AccountGroup.UUID> load(AccountGroup.UUID key) throws Exception {
try (ReviewDb db = schema.open()) {
Set<AccountGroup.Id> ids = Sets.newHashSet();
Set<AccountGroup.Id> ids = new HashSet<>();
for (AccountGroupById agi : db.accountGroupById()
.byIncludeUUID(key)) {
ids.add(agi.getGroupId());
}
Set<AccountGroup.UUID> groupArray = Sets.newHashSet();
Set<AccountGroup.UUID> groupArray = new HashSet<>();
for (AccountGroup g : db.accountGroups().get(ids)) {
groupArray.add(g.getGroupUUID());
}
@@ -199,7 +199,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public Set<AccountGroup.UUID> load(String key) throws Exception {
try (ReviewDb db = schema.open()) {
Set<AccountGroup.UUID> ids = Sets.newHashSet();
Set<AccountGroup.UUID> ids = new HashSet<>();
for (AccountGroupById agi : db.accountGroupById().all()) {
if (!AccountGroup.isInternalGroup(agi.getIncludeUUID())) {
ids.add(agi.getIncludeUUID());

View File

@@ -46,7 +46,7 @@ public interface GroupMembership {
* Implementors may implement the method as:
*
* <pre>
* Set&lt;AccountGroup.UUID&gt; r = Sets.newHashSet();
* Set&lt;AccountGroup.UUID&gt; r = new HashSet<>();
* for (AccountGroup.UUID id : groupIds)
* if (contains(id)) r.add(id);
* </pre>

View File

@@ -22,6 +22,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -102,7 +103,7 @@ public class IncludingGroupMembership implements GroupMembership {
@Override
public Set<AccountGroup.UUID> intersection(Iterable<AccountGroup.UUID> groupIds) {
Set<AccountGroup.UUID> r = Sets.newHashSet();
Set<AccountGroup.UUID> r = new HashSet<>();
for (AccountGroup.UUID id : groupIds) {
if (contains(id)) {
r.add(id);

View File

@@ -35,6 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -180,7 +181,7 @@ public class UniversalGroupBackend implements GroupBackend {
}
lookups.put(m, uuid);
}
Set<AccountGroup.UUID> groups = Sets.newHashSet();
Set<AccountGroup.UUID> groups = new HashSet<>();
for (Map.Entry<GroupMembership, Collection<AccountGroup.UUID>> entry
: lookups.asMap().entrySet()) {
groups.addAll(entry.getKey().intersection(entry.getValue()));
@@ -190,7 +191,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override
public Set<AccountGroup.UUID> getKnownGroups() {
Set<AccountGroup.UUID> groups = Sets.newHashSet();
Set<AccountGroup.UUID> groups = new HashSet<>();
for (GroupMembership m : memberships.values()) {
groups.addAll(m.getKnownGroups());
}

View File

@@ -16,11 +16,11 @@ package com.google.gerrit.server.auth;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
/**
@@ -38,8 +38,8 @@ public final class UniversalAuthBackend implements AuthBackend {
@Override
public AuthUser authenticate(final AuthRequest request) throws AuthException {
List<AuthUser> authUsers = Lists.newArrayList();
List<AuthException> authExs = Lists.newArrayList();
List<AuthUser> authUsers = new ArrayList<>();
List<AuthException> authExs = new ArrayList<>();
for (AuthBackend backend : authBackends) {
try {
authUsers.add(checkNotNull(backend.authenticate(request)));

View File

@@ -125,6 +125,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -280,7 +282,7 @@ public class ChangeJson {
}));
List<List<ChangeInfo>> res = Lists.newArrayListWithCapacity(in.size());
Map<Change.Id, ChangeInfo> out = Maps.newHashMap();
Map<Change.Id, ChangeInfo> out = new HashMap<>();
for (QueryResult r : in) {
List<ChangeInfo> infos = toChangeInfo(out, r.changes());
if (!infos.isEmpty() && r.moreChanges()) {
@@ -610,7 +612,7 @@ public class ChangeJson {
// Include a user in the output for this label if either:
// - They are an explicit reviewer.
// - They ever voted on this change.
Set<Account.Id> allUsers = Sets.newHashSet();
Set<Account.Id> allUsers = new HashSet<>();
allUsers.addAll(cd.reviewers().values());
for (PatchSetApproval psa : cd.approvals().values()) {
allUsers.add(psa.getAccountId());
@@ -667,7 +669,7 @@ public class ChangeJson {
private Map<String, LabelWithStatus> labelsForClosedChange(ChangeData cd,
LabelTypes labelTypes, boolean standard, boolean detailed)
throws OrmException {
Set<Account.Id> allUsers = Sets.newHashSet();
Set<Account.Id> allUsers = new HashSet<>();
if (detailed) {
// Users expect to see all reviewers on closed changes, even if they
// didn't vote on the latest patch set. If we don't need detailed labels,
@@ -680,7 +682,7 @@ public class ChangeJson {
// We can only approximately reconstruct what the submit rule evaluator
// would have done. These should really come from a stored submit record.
Set<String> labelNames = Sets.newHashSet();
Set<String> labelNames = new HashSet<>();
Multimap<Account.Id, PatchSetApproval> current = HashMultimap.create();
for (PatchSetApproval a : cd.currentApprovals()) {
allUsers.add(a.getAccountId());
@@ -755,7 +757,7 @@ public class ChangeJson {
private void setLabelValues(LabelType type, LabelWithStatus l) {
l.label().defaultValue = type.getDefaultValue();
l.label().values = Maps.newLinkedHashMap();
l.label().values = new LinkedHashMap<>();
for (LabelValue v : type.getValues()) {
l.label().values.put(v.formatValue(), v.getText());
}
@@ -871,7 +873,7 @@ public class ChangeJson {
private Map<String, RevisionInfo> revisions(ChangeControl ctl,
Map<PatchSet.Id, PatchSet> map) throws PatchListNotAvailableException,
GpgException, OrmException, IOException {
Map<String, RevisionInfo> res = Maps.newLinkedHashMap();
Map<String, RevisionInfo> res = new LinkedHashMap<>();
for (PatchSet in : map.values()) {
if ((has(ALL_REVISIONS)
|| in.getId().equals(ctl.getChange().currentPatchSetId()))
@@ -1003,7 +1005,7 @@ public class ChangeJson {
private Map<String, FetchInfo> makeFetchMap(ChangeControl ctl, PatchSet in)
throws OrmException {
Map<String, FetchInfo> r = Maps.newLinkedHashMap();
Map<String, FetchInfo> r = new LinkedHashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
String schemeName = e.getExportName();
@@ -1049,7 +1051,7 @@ public class ChangeJson {
private static void addCommand(FetchInfo fetchInfo, String commandName,
String c) {
if (fetchInfo.commands == null) {
fetchInfo.commands = Maps.newTreeMap();
fetchInfo.commands = new TreeMap<>();
}
fetchInfo.commands.put(commandName, c);
}
@@ -1063,7 +1065,7 @@ public class ChangeJson {
private static void addApproval(LabelInfo label, ApprovalInfo approval) {
if (label.all == null) {
label.all = Lists.newArrayList();
label.all = new ArrayList<>();
}
label.all.add(approval);
}

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.change;
import com.google.common.collect.Maps;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.extensions.common.FileInfo;
@@ -33,6 +32,7 @@ import com.google.inject.Singleton;
import org.eclipse.jgit.lib.ObjectId;
import java.util.Map;
import java.util.TreeMap;
@Singleton
public class FileInfoJson {
@@ -57,7 +57,7 @@ public class FileInfoJson {
PatchList list = patchListCache.get(
new PatchListKey(a, b, Whitespace.IGNORE_NONE), change.getProject());
Map<String, FileInfo> files = Maps.newTreeMap();
Map<String, FileInfo> files = new TreeMap<>();
for (PatchListEntry e : list.getPatches()) {
FileInfo d = new FileInfo();
d.status = e.getChangeType() != Patch.ChangeType.MODIFIED

View File

@@ -231,7 +231,7 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
private List<String> scan(Account.Id userId, PatchSet.Id psId)
throws OrmException {
List<String> r = Lists.newArrayList();
List<String> r = new ArrayList<>();
for (AccountPatchReview w : db.get().accountPatchReviews()
.byReviewer(userId, psId)) {
r.add(w.getKey().getPatchKey().getFileName());

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -35,6 +34,8 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -107,8 +108,8 @@ public class IncludedInResolver {
private boolean includedInOne(final Collection<Ref> refs) throws IOException {
parseCommits(refs);
List<RevCommit> before = Lists.newLinkedList();
List<RevCommit> after = Lists.newLinkedList();
List<RevCommit> before = new LinkedList<>();
List<RevCommit> after = new LinkedList<>();
partition(before, after);
// It is highly likely that the target is reachable from the "after" set
// Within the "before" set we are trying to handle cases arising from clock skew
@@ -120,7 +121,7 @@ public class IncludedInResolver {
*/
private Set<String> includedIn(final Collection<RevCommit> tips, int limit)
throws IOException, MissingObjectException, IncorrectObjectTypeException {
Set<String> result = Sets.newHashSet();
Set<String> result = new HashSet<>();
for (RevCommit tip : tips) {
boolean commitFound = false;
rw.resetRetain(RevFlag.UNINTERESTING, containsTarget);

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.change;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -25,6 +24,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -48,7 +48,7 @@ class ListReviewers implements RestReadView<ChangeResource> {
@Override
public List<ReviewerInfo> apply(ChangeResource rsrc) throws OrmException {
Map<Account.Id, ReviewerResource> reviewers = Maps.newLinkedHashMap();
Map<Account.Id, ReviewerResource> reviewers = new LinkedHashMap<>();
ReviewDb db = dbProvider.get();
for (Account.Id accountId
: approvalsUtil.getReviewers(db, rsrc.getNotes()).values()) {

View File

@@ -24,8 +24,6 @@ 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.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.common.hash.HashCode;
@@ -410,8 +408,8 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
}
}
List<PatchLineComment> del = Lists.newArrayList();
List<PatchLineComment> ups = Lists.newArrayList();
List<PatchLineComment> del = new ArrayList<>();
List<PatchLineComment> ups = new ArrayList<>();
Set<CommentSetEntry> existingIds = in.omitDuplicateComments
? readExistingComments(ctx)
@@ -490,7 +488,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private Map<String, PatchLineComment> changeDrafts(ChangeContext ctx)
throws OrmException {
Map<String, PatchLineComment> drafts = Maps.newHashMap();
Map<String, PatchLineComment> drafts = new HashMap<>();
for (PatchLineComment c : plcUtil.draftByChangeAuthor(
ctx.getDb(), ctx.getNotes(), user.getAccountId())) {
c.setTag(in.tag);
@@ -501,7 +499,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private Map<String, PatchLineComment> patchSetDrafts(ChangeContext ctx)
throws OrmException {
Map<String, PatchLineComment> drafts = Maps.newHashMap();
Map<String, PatchLineComment> drafts = new HashMap<>();
for (PatchLineComment c : plcUtil.draftByPatchSetAuthor(ctx.getDb(),
psId, user.getAccountId(), ctx.getNotes())) {
drafts.put(c.getKey().get(), c);
@@ -588,8 +586,8 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
return false;
}
List<PatchSetApproval> del = Lists.newArrayList();
List<PatchSetApproval> ups = Lists.newArrayList();
List<PatchSetApproval> del = new ArrayList<>();
List<PatchSetApproval> ups = new ArrayList<>();
Map<String, PatchSetApproval> current = scanLabels(ctx, del);
LabelTypes labelTypes = ctx.getControl().getLabelTypes();
Map<String, Short> allApprovals = getAllApprovals(labelTypes,
@@ -690,7 +688,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private Map<String, PatchSetApproval> scanLabels(ChangeContext ctx,
List<PatchSetApproval> del) throws OrmException {
LabelTypes labelTypes = ctx.getControl().getLabelTypes();
Map<String, PatchSetApproval> current = Maps.newHashMap();
Map<String, PatchSetApproval> current = new HashMap<>();
for (PatchSetApproval a : approvalsUtil.byPatchSetUser(
ctx.getDb(), ctx.getControl(), psId, user.getAccountId())) {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.GroupDescription;
@@ -63,6 +62,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -170,7 +170,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
return result;
}
Map<Account.Id, ChangeControl> reviewers = Maps.newHashMap();
Map<Account.Id, ChangeControl> reviewers = new HashMap<>();
ChangeControl control = rsrc.getControl();
Set<Account> members;
try {

View File

@@ -35,6 +35,7 @@ import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -113,7 +114,7 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour
// Impossibly long identifier will never match.
return Collections.emptyList();
} else {
List<RevisionResource> out = Lists.newArrayList();
List<RevisionResource> out = new ArrayList<>();
for (PatchSet ps : psUtil.byChange(dbProvider.get(), change.getNotes())) {
if (ps.getRevision() != null && ps.getRevision().get().startsWith(id)) {
out.add(new RevisionResource(change, ps));

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.TestSubmitRuleInput;
@@ -34,6 +33,7 @@ import com.google.inject.Provider;
import org.kohsuke.args4j.Option;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -116,31 +116,31 @@ public class TestSubmitRule
switch (n.status) {
case OK:
if (ok == null) {
ok = Maps.newLinkedHashMap();
ok = new LinkedHashMap<>();
}
ok.put(n.label, who);
break;
case REJECT:
if (reject == null) {
reject = Maps.newLinkedHashMap();
reject = new LinkedHashMap<>();
}
reject.put(n.label, who);
break;
case NEED:
if (need == null) {
need = Maps.newLinkedHashMap();
need = new LinkedHashMap<>();
}
need.put(n.label, new None());
break;
case MAY:
if (may == null) {
may = Maps.newLinkedHashMap();
may = new LinkedHashMap<>();
}
may.put(n.label, who);
break;
case IMPOSSIBLE:
if (impossible == null) {
impossible = Maps.newLinkedHashMap();
impossible = new LinkedHashMap<>();
}
impossible.put(n.label, new None());
break;

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.config;
import com.google.common.base.CharMatcher;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.config.CapabilityDefinition;
import com.google.gerrit.extensions.registration.DynamicMap;
@@ -28,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.TreeMap;
/** List capabilities visible to the calling user. */
@Singleton
@@ -43,7 +43,7 @@ public class ListCapabilities implements RestReadView<ConfigResource> {
@Override
public Map<String, CapabilityInfo> apply(ConfigResource resource)
throws IllegalAccessException, NoSuchFieldException {
Map<String, CapabilityInfo> output = Maps.newTreeMap();
Map<String, CapabilityInfo> output = new TreeMap<>();
collectCoreCapabilities(output);
collectPluginCapabilities(output);
return output;

View File

@@ -14,13 +14,13 @@
package com.google.gerrit.server.config;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
@Singleton
@@ -34,7 +34,7 @@ class ListTopMenus implements RestReadView<ConfigResource> {
@Override
public List<TopMenu.MenuEntry> apply(ConfigResource resource) {
List<TopMenu.MenuEntry> entries = Lists.newArrayList();
List<TopMenu.MenuEntry> entries = new ArrayList<>();
for (TopMenu extension : extensions) {
entries.addAll(extension.getEntries());
}

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.config;
import com.google.common.collect.Maps;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.git.ProjectLevelConfig;
import com.google.gerrit.server.plugins.Plugin;
@@ -36,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
@Singleton
@@ -60,7 +60,7 @@ public class PluginConfigFactory implements ReloadPluginListener {
this.cfgProvider = cfgProvider;
this.projectCache = projectCache;
this.projectStateFactory = projectStateFactory;
this.pluginConfigs = Maps.newHashMap();
this.pluginConfigs = new HashMap<>();
this.cfgSnapshot = FileSnapshot.save(site.gerrit_config.toFile());
this.cfg = cfgProvider.get();

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.edit;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.FetchInfo;
@@ -31,6 +30,7 @@ import com.google.inject.Singleton;
import org.eclipse.jgit.revwalk.RevCommit;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
@Singleton
@@ -78,7 +78,7 @@ public class ChangeEditJson {
}
private Map<String, FetchInfo> fillFetchMap(ChangeEdit edit) {
Map<String, FetchInfo> r = Maps.newLinkedHashMap();
Map<String, FetchInfo> r = new LinkedHashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
String schemeName = e.getExportName();
DownloadScheme scheme = e.getProvider().get();

View File

@@ -19,11 +19,12 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.inject.Singleton;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Singleton
public class GarbageCollectionQueue {
private final Set<Project.NameKey> projectsScheduledForGc = Sets.newHashSet();
private final Set<Project.NameKey> projectsScheduledForGc = new HashSet<>();
public synchronized Set<Project.NameKey> addAll(Collection<Project.NameKey> projects) {
Set<Project.NameKey> added =

View File

@@ -17,12 +17,12 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Maps;
import com.google.gerrit.common.Nullable;
import org.eclipse.jgit.lib.ObjectId;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
@@ -50,7 +50,7 @@ public class MergeTip {
checkArgument(!toMerge.isEmpty(), "toMerge may not be empty");
this.initialTip = initialTip;
this.branchTip = initialTip;
this.mergeResults = Maps.newHashMap();
this.mergeResults = new HashMap<>();
// Assume fast-forward merge until opposite is proven.
for (CodeReviewCommit commit : toMerge) {
mergeResults.put(commit.copy(), commit.copy());

View File

@@ -15,12 +15,12 @@
package com.google.gerrit.server.git;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
import com.google.gerrit.server.mail.Address;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class NotifyConfig implements Comparable<NotifyConfig> {
@@ -33,8 +33,8 @@ public class NotifyConfig implements Comparable<NotifyConfig> {
private String filter;
private Header header;
private Set<GroupReference> groups = Sets.newHashSet();
private Set<Address> addresses = Sets.newHashSet();
private Set<GroupReference> groups = new HashSet<>();
private Set<Address> addresses = new HashSet<>();
public String getName() {
return name;

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.git;
import com.google.common.collect.Maps;
import com.google.gerrit.server.config.RequestScopedReviewDbProvider;
import com.google.gerrit.server.util.RequestContext;
import com.google.gerrit.server.util.ThreadLocalRequestContext;
@@ -25,6 +24,7 @@ import com.google.inject.OutOfScopeException;
import com.google.inject.Provider;
import com.google.inject.Scope;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -37,7 +37,7 @@ public class PerThreadRequestScope {
private final Map<Key<?>, Object> map;
private Context() {
map = Maps.newHashMap();
map = new HashMap<>();
}
private <T> T get(Key<T> key, Provider<T> creator) {

View File

@@ -69,6 +69,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -527,7 +528,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
*/
private void loadNotifySections(
Config rc, Map<String, GroupReference> groupsByName) {
notifySections = Maps.newHashMap();
notifySections = new HashMap<>();
for (String sectionName : rc.getSubsections(NOTIFY)) {
NotifyConfig n = new NotifyConfig();
n.setName(sectionName);
@@ -683,7 +684,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
private void loadLabelSections(Config rc) {
Map<String, String> lowerNames = Maps.newHashMapWithExpectedSize(2);
labelSections = Maps.newLinkedHashMap();
labelSections = new LinkedHashMap<>();
for (String name : rc.getSubsections(LABEL)) {
String lower = name.toLowerCase();
if (lowerNames.containsKey(lower)) {
@@ -693,7 +694,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
}
lowerNames.put(lower, name);
List<LabelValue> values = Lists.newArrayList();
List<LabelValue> values = new ArrayList<>();
for (String value : rc.getStringList(LABEL, name, KEY_VALUE)) {
try {
values.add(parseLabelValue(value));
@@ -818,7 +819,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
}
private void loadPluginSections(Config rc) {
pluginConfigs = Maps.newHashMap();
pluginConfigs = new HashMap<>();
for (String plugin : rc.getSubsections(PLUGIN)) {
Config pluginConfig = new Config();
pluginConfigs.put(plugin, pluginConfig);
@@ -973,7 +974,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
private void saveNotifySections(
Config rc, Set<AccountGroup.UUID> keepGroups) {
for (NotifyConfig nc : sort(notifySections.values())) {
List<String> email = Lists.newArrayList();
List<String> email = new ArrayList<>();
for (GroupReference gr : nc.getGroups()) {
if (gr.getUUID() != null) {
keepGroups.add(gr.getUUID());
@@ -982,7 +983,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
}
Collections.sort(email);
List<String> addrs = Lists.newArrayList();
List<String> addrs = new ArrayList<>();
for (Address addr : nc.getAddresses()) {
addrs.add(addr.toString());
}

View File

@@ -631,7 +631,7 @@ public class ReceiveCommits {
rp.sendMessage(COMMAND_REJECTION_MESSAGE_FOOTER);
}
Set<Branch.NameKey> branches = Sets.newHashSet();
Set<Branch.NameKey> branches = new HashSet<>();
for (ReceiveCommand c : commands) {
if (c.getResult() == OK) {
if (c.getType() == ReceiveCommand.Type.UPDATE) { // aka fast-forward
@@ -789,7 +789,7 @@ public class ReceiveCommits {
return;
}
List<String> lastCreateChangeErrors = Lists.newArrayList();
List<String> lastCreateChangeErrors = new ArrayList<>();
for (CreateRequest create : newChanges) {
if (create.cmd.getResult() == OK) {
okToInsert++;
@@ -819,7 +819,7 @@ public class ReceiveCommits {
}
try {
List<CheckedFuture<?, RestApiException>> futures = Lists.newArrayList();
List<CheckedFuture<?, RestApiException>> futures = new ArrayList<>();
for (ReplaceRequest replace : replaceByChange.values()) {
if (replace.inputCommand == magicBranch.cmd) {
futures.add(replace.insertPatchSet());
@@ -1504,7 +1504,7 @@ public class ReceiveCommits {
}
private void selectNewAndReplacedChangesFromMagicBranch() {
newChanges = Lists.newArrayList();
newChanges = new ArrayList<>();
SetMultimap<ObjectId, Ref> existing = changeRefsById();
GroupCollector groupCollector = GroupCollector.create(refsById, db, psUtil,
@@ -1531,7 +1531,7 @@ public class ReceiveCommits {
magicBranch.ctl != null ? magicBranch.ctl.getRefName() : null);
}
List<ChangeLookup> pending = Lists.newArrayList();
List<ChangeLookup> pending = new ArrayList<>();
Set<Change.Key> newChangeIds = new HashSet<>();
int maxBatchChanges =
receiveConfig.getEffectiveMaxBatchChangesLimit(user);

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.git;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
@@ -50,6 +49,7 @@ import org.eclipse.jgit.util.RawParseUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -479,7 +479,7 @@ public abstract class VersionedMetaData {
TreeWalk tw = new TreeWalk(reader);
tw.addTree(revision.getTree());
tw.setRecursive(recursive);
List<PathInfo> paths = Lists.newArrayList();
List<PathInfo> paths = new ArrayList<>();
while (tw.next()) {
paths.add(new PathInfo(tw));
}

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.git;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFutureTask;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
@@ -129,7 +128,7 @@ public class WorkQueue {
}
public <T> List<T> getTaskInfos(TaskInfoFactory<T> factory) {
List<T> taskInfos = Lists.newArrayList();
List<T> taskInfos = new ArrayList<>();
for (Executor exe : queues) {
for (Task<?> task : exe.getTasks()) {
taskInfos.add(factory.getTaskInfo(task));

View File

@@ -21,7 +21,6 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
@@ -63,6 +62,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -327,7 +327,7 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
private LabelNormalizer.Result approve(ChangeContext ctx, ChangeUpdate update)
throws OrmException {
PatchSet.Id psId = update.getPatchSetId();
Map<PatchSetApproval.Key, PatchSetApproval> byKey = Maps.newHashMap();
Map<PatchSetApproval.Key, PatchSetApproval> byKey = new HashMap<>();
for (PatchSetApproval psa : args.approvalsUtil.byPatchSet(
ctx.getDb(), ctx.getControl(), psId)) {
byKey.put(psa.getKey(), psa);

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.git.validators;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
import com.google.gerrit.extensions.registration.DynamicSet;
@@ -36,6 +35,7 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Repository;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class MergeValidators {
@@ -60,7 +60,7 @@ public class MergeValidators {
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
List<MergeValidationListener> validators = Lists.newLinkedList();
List<MergeValidationListener> validators = new LinkedList<>();
validators.add(new PluginMergeValidationListener(mergeValidationListeners));
validators.add(projectConfigValidatorFactory.create());

View File

@@ -15,7 +15,6 @@ package com.google.gerrit.server.git.validators;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
@@ -29,6 +28,7 @@ import org.eclipse.jgit.transport.ReceiveCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class RefOperationValidators {
@@ -63,7 +63,7 @@ public class RefOperationValidators {
public List<ValidationMessage> validateForRefOperation()
throws RefOperationValidationException {
List<ValidationMessage> messages = Lists.newArrayList();
List<ValidationMessage> messages = new ArrayList<>();
boolean withException = false;
try {
for (RefOperationValidationListener listener : refOperationValidationListeners) {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.group;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.extensions.common.GroupInfo;
@@ -39,6 +38,8 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -98,8 +99,8 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
input = Input.init(input);
GroupControl control = resource.getControl();
Map<AccountGroup.UUID, AccountGroupById> newIncludedGroups = Maps.newHashMap();
List<GroupInfo> result = Lists.newLinkedList();
Map<AccountGroup.UUID, AccountGroupById> newIncludedGroups = new HashMap<>();
List<GroupInfo> result = new LinkedList<>();
Account.Id me = control.getUser().getAccountId();
for (String includedGroup : input.groups) {

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.group;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.restapi.AuthException;
@@ -47,7 +46,9 @@ import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -174,7 +175,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
public void addMembers(AccountGroup.Id groupId,
Collection<? extends Account.Id> newMemberIds) throws OrmException {
Map<Account.Id, AccountGroupMember> newAccountGroupMembers = Maps.newHashMap();
Map<Account.Id, AccountGroupMember> newAccountGroupMembers = new HashMap<>();
for (Account.Id accId : newMemberIds) {
if (!newAccountGroupMembers.containsKey(accId)) {
AccountGroupMember.Key key =
@@ -212,7 +213,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
private List<AccountInfo> toAccountInfoList(Set<Account.Id> accountIds)
throws OrmException {
List<AccountInfo> result = Lists.newLinkedList();
List<AccountInfo> result = new LinkedList<>();
AccountLoader loader = infoFactory.create(true);
for (Account.Id accId : accountIds) {
result.add(loader.get(accId));

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.group;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.gerrit.audit.GroupMemberAuditListener;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.reviewdb.client.Account;
@@ -37,6 +36,7 @@ import org.slf4j.Logger;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
class DbGroupMemberAuditListener implements GroupMemberAuditListener {
@@ -61,7 +61,7 @@ class DbGroupMemberAuditListener implements GroupMemberAuditListener {
@Override
public void onAddAccountsToGroup(Account.Id me,
Collection<AccountGroupMember> added) {
List<AccountGroupMemberAudit> auditInserts = Lists.newLinkedList();
List<AccountGroupMemberAudit> auditInserts = new LinkedList<>();
for (AccountGroupMember m : added) {
AccountGroupMemberAudit audit =
new AccountGroupMemberAudit(m, me, TimeUtil.nowTs());
@@ -79,8 +79,8 @@ class DbGroupMemberAuditListener implements GroupMemberAuditListener {
@Override
public void onDeleteAccountsFromGroup(Account.Id me,
Collection<AccountGroupMember> removed) {
List<AccountGroupMemberAudit> auditInserts = Lists.newLinkedList();
List<AccountGroupMemberAudit> auditUpdates = Lists.newLinkedList();
List<AccountGroupMemberAudit> auditInserts = new LinkedList<>();
List<AccountGroupMemberAudit> auditUpdates = new LinkedList<>();
try (ReviewDb db = schema.open()) {
for (AccountGroupMember m : removed) {
AccountGroupMemberAudit audit = null;
@@ -131,7 +131,7 @@ class DbGroupMemberAuditListener implements GroupMemberAuditListener {
@Override
public void onDeleteGroupsFromGroup(Account.Id me,
Collection<AccountGroupById> removed) {
final List<AccountGroupByIdAud> auditUpdates = Lists.newLinkedList();
final List<AccountGroupByIdAud> auditUpdates = new LinkedList<>();
try (ReviewDb db = schema.open()) {
for (final AccountGroupById g : removed) {
AccountGroupByIdAud audit = null;

View File

@@ -15,8 +15,6 @@
package com.google.gerrit.server.group;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.extensions.restapi.AuthException;
@@ -37,6 +35,8 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -71,7 +71,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
final GroupControl control = resource.getControl();
final Map<AccountGroup.UUID, AccountGroupById> includedGroups = getIncludedGroups(internalGroup.getId());
final List<AccountGroupById> toRemove = Lists.newLinkedList();
final List<AccountGroupById> toRemove = new LinkedList<>();
for (final String includedGroup : input.groups) {
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
@@ -100,8 +100,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
private Map<AccountGroup.UUID, AccountGroupById> getIncludedGroups(
final AccountGroup.Id groupId) throws OrmException {
final Map<AccountGroup.UUID, AccountGroupById> groups =
Maps.newHashMap();
final Map<AccountGroup.UUID, AccountGroupById> groups = new HashMap<>();
for (AccountGroupById g : db.get().accountGroupById().byGroup(groupId)) {
groups.put(g.getIncludeUUID(), g);
}

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.server.group;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
@@ -36,6 +34,8 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -71,7 +71,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
final GroupControl control = resource.getControl();
final Map<Account.Id, AccountGroupMember> members = getMembers(internalGroup.getId());
final List<AccountGroupMember> toRemove = Lists.newLinkedList();
final List<AccountGroupMember> toRemove = new LinkedList<>();
for (final String nameOrEmail : input.members) {
Account a = accounts.parse(nameOrEmail).getAccount();
@@ -102,7 +102,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
private Map<Account.Id, AccountGroupMember> getMembers(
final AccountGroup.Id groupId) throws OrmException {
final Map<Account.Id, AccountGroupMember> members = Maps.newHashMap();
final Map<Account.Id, AccountGroupMember> members = new HashMap<>();
for (final AccountGroupMember m : db.get().accountGroupMembers()
.byGroup(groupId)) {
members.put(m.getAccountId(), m);

View File

@@ -14,12 +14,12 @@
package com.google.gerrit.server.group;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupBackend;
import com.google.inject.Inject;
import java.util.HashMap;
import java.util.Map;
/** Efficiently builds a {@link GroupInfoCache}. */
@@ -34,7 +34,7 @@ public class GroupInfoCacheFactory {
@Inject
GroupInfoCacheFactory(GroupBackend groupBackend) {
this.groupBackend = groupBackend;
this.out = Maps.newHashMap();
this.out = new HashMap<>();
}
/**

View File

@@ -18,8 +18,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.data.GroupReference;
@@ -49,11 +47,14 @@ import org.kohsuke.args4j.Option;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
/** List groups visible to the calling user. */
public class ListGroups implements RestReadView<TopLevelResource> {
@@ -61,7 +62,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
protected final GroupCache groupCache;
private final List<ProjectControl> projects = new ArrayList<>();
private final Set<AccountGroup.UUID> groupsToInspect = Sets.newHashSet();
private final Set<AccountGroup.UUID> groupsToInspect = new HashSet<>();
private final GroupControl.Factory groupControlFactory;
private final GroupControl.GenericFactory genericGroupControlFactory;
private final Provider<IdentifiedUser> identifiedUser;
@@ -177,7 +178,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
@Override
public SortedMap<String, GroupInfo> apply(TopLevelResource resource)
throws OrmException, BadRequestException {
SortedMap<String, GroupInfo> output = Maps.newTreeMap();
SortedMap<String, GroupInfo> output = new TreeMap<>();
for (GroupInfo info : get()) {
output.put(MoreObjects.firstNonNull(
info.name,
@@ -209,7 +210,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
List<GroupInfo> groupInfos;
List<AccountGroup> groupList;
if (!projects.isEmpty()) {
Map<AccountGroup.UUID, AccountGroup> groups = Maps.newHashMap();
Map<AccountGroup.UUID, AccountGroup> groups = new HashMap<>();
for (final ProjectControl projectControl : projects) {
final Set<GroupReference> groupsRefs = projectControl.getAllGroups();
for (final GroupReference groupRef : groupsRefs) {
@@ -290,7 +291,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
private List<GroupInfo> getGroupsOwnedBy(IdentifiedUser user)
throws OrmException {
List<GroupInfo> groups = Lists.newArrayList();
List<GroupInfo> groups = new ArrayList<>();
int found = 0;
int foundIndex = 0;
for (AccountGroup g : filterGroups(groupCache.all())) {
@@ -314,7 +315,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
}
private List<AccountGroup> filterGroups(final Iterable<AccountGroup> groups) {
final List<AccountGroup> filteredGroups = Lists.newArrayList();
final List<AccountGroup> filteredGroups = new ArrayList<>();
final boolean isAdmin =
identifiedUser.get().getCapabilities().canAdministrateServer();
for (final AccountGroup group : groups) {

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.group;
import static com.google.common.base.Strings.nullToEmpty;
import com.google.common.collect.Lists;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
@@ -31,6 +30,7 @@ import com.google.inject.Singleton;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -59,7 +59,7 @@ public class ListIncludedGroups implements RestReadView<GroupResource> {
}
boolean ownerOfParent = rsrc.getControl().isOwner();
List<GroupInfo> included = Lists.newArrayList();
List<GroupInfo> included = new ArrayList<>();
for (AccountGroupById u : dbProvider.get()
.accountGroupById()
.byGroup(rsrc.toAccountGroup().getId())) {

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.group;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.GroupDetail;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.AccountInfo;
@@ -35,6 +34,7 @@ import com.google.inject.Inject;
import org.kohsuke.args4j.Option;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -90,7 +90,7 @@ public class ListMembers implements RestReadView<GroupResource> {
final HashSet<AccountGroup.UUID> seenGroups) throws OrmException {
seenGroups.add(groupUUID);
final Map<Account.Id, AccountInfo> members = Maps.newHashMap();
final Map<Account.Id, AccountInfo> members = new HashMap<>();
final AccountGroup group = groupCache.get(groupUUID);
if (group == null) {
// the included group is an external group and can't be resolved

View File

@@ -22,8 +22,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.eclipse.jgit.lib.PersonIdent;
@@ -32,6 +30,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,7 @@ import java.util.Set;
public class SchemaUtil {
public static <V> ImmutableSortedMap<Integer, Schema<V>> schemasFromClass(
Class<?> schemasClass, Class<V> valueClass) {
Map<Integer, Schema<V>> schemas = Maps.newHashMap();
Map<Integer, Schema<V>> schemas = new HashMap<>();
for (Field f : schemasClass.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers())
&& Modifier.isFinal(f.getModifiers())
@@ -100,7 +99,7 @@ public class SchemaUtil {
Iterable<String> emails) {
Splitter at = Splitter.on('@');
Splitter s = Splitter.on(CharMatcher.anyOf("@.- ")).omitEmptyStrings();
HashSet<String> parts = Sets.newHashSet();
HashSet<String> parts = new HashSet<>();
for (String email : emails) {
if (email == null) {
continue;

View File

@@ -66,6 +66,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -147,7 +148,7 @@ public class AllChangesIndexer
totalWork >= 0 ? totalWork : MultiProgressMonitor.UNKNOWN);
final Task failedTask = mpm.beginSubTask("failed", MultiProgressMonitor.UNKNOWN);
final List<ListenableFuture<?>> futures = Lists.newArrayList();
final List<ListenableFuture<?>> futures = new ArrayList<>();
final AtomicBoolean ok = new AtomicBoolean(true);
for (final Project.NameKey project : projects) {

View File

@@ -222,7 +222,7 @@ public class ChangeField {
return ImmutableSet.of();
}
Splitter s = Splitter.on('/').omitEmptyStrings();
Set<String> r = Sets.newHashSet();
Set<String> r = new HashSet<>();
for (String path : paths) {
for (String part : s.split(path)) {
r.add(part);
@@ -302,7 +302,7 @@ public class ChangeField {
if (c == null) {
return ImmutableSet.of();
}
Set<Integer> r = Sets.newHashSet();
Set<Integer> r = new HashSet<>();
if (!args.allowsDrafts && c.getStatus() == Change.Status.DRAFT) {
return r;
}
@@ -336,7 +336,7 @@ public class ChangeField {
};
private static Set<String> getRevisions(ChangeData cd) throws OrmException {
Set<String> revisions = Sets.newHashSet();
Set<String> revisions = new HashSet<>();
for (PatchSet ps : cd.patchSets()) {
if (ps.getRevision() != null) {
revisions.add(ps.getRevision().get());
@@ -372,8 +372,8 @@ public class ChangeField {
@Override
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> allApprovals = Sets.newHashSet();
Set<String> distinctApprovals = Sets.newHashSet();
Set<String> allApprovals = new HashSet<>();
Set<String> distinctApprovals = new HashSet<>();
for (PatchSetApproval a : input.currentApprovals()) {
if (a.getValue() != 0 && !a.isLegacySubmit()) {
allApprovals.add(formatLabel(a.getLabel(), a.getValue(),
@@ -505,7 +505,7 @@ public class ChangeField {
@Override
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> r = Sets.newHashSet();
Set<String> r = new HashSet<>();
for (PatchLineComment c : input.publishedComments()) {
r.add(c.getMessage());
}

View File

@@ -16,9 +16,9 @@ package com.google.gerrit.server.mail;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -18,7 +18,6 @@ import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailSt
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.DISABLED;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.Sets;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
@@ -63,7 +62,7 @@ public abstract class OutgoingEmail {
protected String messageClass;
private final HashSet<Account.Id> rcptTo = new HashSet<>();
private final Map<String, EmailHeader> headers;
private final Set<Address> smtpRcptTo = Sets.newHashSet();
private final Set<Address> smtpRcptTo = new HashSet<>();
private Address smtpFromAddress;
private StringBuilder body;
protected VelocityContext velocityContext;

View File

@@ -15,8 +15,6 @@
package com.google.gerrit.server.mail;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.data.GroupReference;
@@ -41,6 +39,7 @@ import com.google.gwtorm.server.OrmException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -100,8 +99,8 @@ public class ProjectWatch {
public static class Watchers {
static class List {
protected final Set<Account.Id> accounts = Sets.newHashSet();
protected final Set<Address> emails = Sets.newHashSet();
protected final Set<Account.Id> accounts = new HashSet<>();
protected final Set<Address> emails = new HashSet<>();
}
protected final List to = new List();
protected final List cc = new List();
@@ -141,8 +140,8 @@ public class ProjectWatch {
Watchers.List matching,
AccountGroup.UUID startUUID) throws OrmException {
ReviewDb db = args.db.get();
Set<AccountGroup.UUID> seen = Sets.newHashSet();
List<AccountGroup.UUID> q = Lists.newArrayList();
Set<AccountGroup.UUID> seen = new HashSet<>();
List<AccountGroup.UUID> q = new ArrayList<>();
seen.add(startUUID);
q.add(startUUID);

View File

@@ -21,7 +21,6 @@ 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.Lists;
import com.google.common.collect.Multimap;
import com.google.common.primitives.Ints;
import com.google.gerrit.reviewdb.client.Account;
@@ -54,6 +53,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -147,7 +147,7 @@ public class ChangeNoteUtil {
return ImmutableList.of();
}
Set<PatchLineComment.Key> seen = new HashSet<>();
List<PatchLineComment> result = Lists.newArrayList();
List<PatchLineComment> result = new ArrayList<>();
int sizeOfNote = note.length;
byte[] psb = PATCH_SET.getBytes(UTF_8);
byte[] bpsb = BASE_PATCH_SET.getBytes(UTF_8);

View File

@@ -82,7 +82,9 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -139,15 +141,15 @@ class ChangeNotesParser implements AutoCloseable {
this.repo = repoManager.openRepository(project);
this.noteUtil = noteUtil;
this.metrics = metrics;
approvals = Maps.newHashMap();
reviewers = Maps.newLinkedHashMap();
allPastReviewers = Lists.newArrayList();
approvals = new HashMap<>();
reviewers = new LinkedHashMap<>();
allPastReviewers = new ArrayList<>();
submitRecords = Lists.newArrayListWithExpectedSize(1);
allChangeMessages = Lists.newArrayList();
allChangeMessages = new ArrayList<>();
changeMessagesByPatchSet = LinkedListMultimap.create();
comments = ArrayListMultimap.create();
patchSets = Maps.newTreeMap(ReviewDbUtil.intKeyOrdering());
patchSetStates = Maps.newHashMap();
patchSetStates = new HashMap<>();
}
@Override
@@ -644,7 +646,7 @@ class ChangeNotesParser implements AutoCloseable {
new Supplier<Map<Entry<String, String>, Optional<PatchSetApproval>>>() {
@Override
public Map<Entry<String, String>, Optional<PatchSetApproval>> get() {
return Maps.newLinkedHashMap();
return new LinkedHashMap<>();
}
});
approvals.put(psId, curr);
@@ -674,7 +676,7 @@ class ChangeNotesParser implements AutoCloseable {
checkFooter(rec != null, FOOTER_SUBMITTED_WITH, line);
SubmitRecord.Label label = new SubmitRecord.Label();
if (rec.labels == null) {
rec.labels = Lists.newArrayList();
rec.labels = new ArrayList<>();
}
rec.labels.add(label);

View File

@@ -32,7 +32,6 @@ import com.google.common.collect.ComparisonChain;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
@@ -231,7 +230,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
Change change = new Change(bundle.getChange());
// We will rebuild all events, except for draft comments, in buckets based
// on author and timestamp.
List<Event> events = Lists.newArrayList();
List<Event> events = new ArrayList<>();
Multimap<Account.Id, PatchLineCommentEvent> draftCommentEvents =
ArrayListMultimap.create();

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.plugins;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.server.plugins.Plugin.ApiType;
import com.google.inject.Module;
@@ -26,6 +25,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.jar.Manifest;
@@ -85,7 +85,7 @@ public abstract class AbstractPreloadedPluginScanner implements
ImmutableMap.builder();
for (Class<? extends Annotation> annotation : annotations) {
Set<ExtensionMetaData> classMetaDataSet = Sets.newHashSet();
Set<ExtensionMetaData> classMetaDataSet = new HashSet<>();
result.put(annotation, classMetaDataSet);
for (Class<?> clazz : preloadedClasses) {

View File

@@ -20,7 +20,6 @@ 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.Sets;
import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.annotations.Listen;
@@ -40,6 +39,7 @@ import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -78,7 +78,7 @@ class AutoRegisterModules {
}
AutoRegisterModules discover() throws InvalidPluginException {
sysSingletons = Sets.newHashSet();
sysSingletons = new HashSet<>();
sysListen = LinkedListMultimap.create();
initJs = null;

View File

@@ -27,7 +27,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.eclipse.jgit.util.IO;
import org.objectweb.asm.AnnotationVisitor;
@@ -47,6 +46,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -77,10 +78,10 @@ public class JarScanner implements PluginContentScanner {
public Map<Class<? extends Annotation>, Iterable<ExtensionMetaData>> scan(
String pluginName, Iterable<Class<? extends Annotation>> annotations)
throws InvalidPluginException {
Set<String> descriptors = Sets.newHashSet();
Set<String> descriptors = new HashSet<>();
Multimap<String, JarScanner.ClassData> rawMap = ArrayListMultimap.create();
Map<Class<? extends Annotation>, String> classObjToClassDescr =
Maps.newHashMap();
new HashMap<>();
for (Class<? extends Annotation> annotation : annotations) {
String descriptor = Type.getType(annotation).getDescriptor();

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.plugins;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.restapi.RestReadView;
@@ -34,6 +33,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/** List the installed plugins. */
@RequiresCapability(GlobalCapability.VIEW_PLUGINS)
@@ -63,7 +63,7 @@ public class ListPlugins implements RestReadView<TopLevelResource> {
});
if (stdout == null) {
Map<String, PluginInfo> output = Maps.newTreeMap();
Map<String, PluginInfo> output = new TreeMap<>();
for (Plugin p : plugins) {
PluginInfo info = new PluginInfo(p);
output.put(p.getName(), info);

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.plugins;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.extensions.registration.ReloadableRegistrationHandle;
@@ -26,6 +25,7 @@ import com.google.inject.Injector;
import org.eclipse.jgit.internal.storage.file.FileSnapshot;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.jar.Attributes;
@@ -146,7 +146,7 @@ public abstract class Plugin {
if (manager != null) {
if (handle instanceof ReloadableRegistrationHandle) {
if (reloadableHandles == null) {
reloadableHandles = Lists.newArrayList();
reloadableHandles = new ArrayList<>();
}
reloadableHandles.add((ReloadableRegistrationHandle<?>) handle);
}

View File

@@ -22,8 +22,6 @@ import static com.google.gerrit.extensions.registration.PrivateInternals_Dynamic
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.Sets;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.annotations.RootRelative;
import com.google.gerrit.extensions.events.LifecycleListener;
@@ -56,7 +54,9 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -347,7 +347,7 @@ public class PluginGuiceEnvironment {
PrivateInternals_DynamicMapImpl<Object> map =
(PrivateInternals_DynamicMapImpl<Object>) e.getValue();
Map<Annotation, ReloadableRegistrationHandle<?>> am = Maps.newHashMap();
Map<Annotation, ReloadableRegistrationHandle<?>> am = new HashMap<>();
for (ReloadableRegistrationHandle<?> h : oldHandles.get(type)) {
Annotation a = h.getKey().getAnnotation();
if (a != null && !UNIQUE_ANNOTATION.isInstance(a)) {
@@ -402,7 +402,7 @@ public class PluginGuiceEnvironment {
// Index all old handles that match this DynamicSet<T> keyed by
// annotations. Ignore the unique annotations, thereby favoring
// the @Named annotations or some other non-unique naming.
Map<Annotation, ReloadableRegistrationHandle<?>> am = Maps.newHashMap();
Map<Annotation, ReloadableRegistrationHandle<?>> am = new HashMap<>();
List<ReloadableRegistrationHandle<?>> old = oldHandles.get(type);
Iterator<ReloadableRegistrationHandle<?>> oi = old.iterator();
while (oi.hasNext()) {
@@ -510,8 +510,8 @@ public class PluginGuiceEnvironment {
}
private Module copy(Injector src) {
Set<TypeLiteral<?>> dynamicTypes = Sets.newHashSet();
Set<TypeLiteral<?>> dynamicItemTypes = Sets.newHashSet();
Set<TypeLiteral<?>> dynamicTypes = new HashSet<>();
Set<TypeLiteral<?>> dynamicItemTypes = new HashSet<>();
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
TypeLiteral<?> type = e.getKey().getTypeLiteral();
if (type.getRawType() == DynamicItem.class) {
@@ -524,7 +524,7 @@ public class PluginGuiceEnvironment {
}
}
final Map<Key<?>, Binding<?>> bindings = Maps.newLinkedHashMap();
final Map<Key<?>, Binding<?>> bindings = new LinkedHashMap<>();
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
if (dynamicTypes.contains(e.getKey().getTypeLiteral())
&& e.getKey().getAnnotation() != null) {

View File

@@ -25,7 +25,6 @@ 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.Queues;
import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -56,10 +55,12 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.AbstractMap;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -114,8 +115,8 @@ public class PluginLoader implements LifecycleListener {
pluginUserFactory = puf;
running = Maps.newConcurrentMap();
disabled = Maps.newConcurrentMap();
broken = Maps.newHashMap();
toCleanup = Queues.newArrayDeque();
broken = new HashMap<>();
toCleanup = new ArrayDeque<>();
cleanupHandles = Maps.newConcurrentMap();
cleaner = pct;
urlProvider = provider;
@@ -659,8 +660,8 @@ public class PluginLoader implements LifecycleListener {
assert winner != null;
// Disable all loser plugins by renaming their file names to
// "file.disabled" and replace the disabled files in the multimap.
Collection<Path> elementsToRemove = Lists.newArrayList();
Collection<Path> elementsToAdd = Lists.newArrayList();
Collection<Path> elementsToRemove = new ArrayList<>();
Collection<Path> elementsToAdd = new ArrayList<>();
for (Path loser : Iterables.skip(enabled, 1)) {
log.warn(String.format("Plugin <%s> was disabled, because"
+ " another plugin <%s>"

View File

@@ -30,6 +30,8 @@ import org.eclipse.jgit.internal.storage.file.FileSnapshot;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -198,7 +200,7 @@ public class ServerPlugin extends Plugin {
}
if (env.hasSshModule()) {
List<Module> modules = Lists.newLinkedList();
List<Module> modules = new LinkedList<>();
if (getApiType() == ApiType.PLUGIN) {
modules.add(env.getSshModule());
}
@@ -214,7 +216,7 @@ public class ServerPlugin extends Plugin {
}
if (env.hasHttpModule()) {
List<Module> modules = Lists.newLinkedList();
List<Module> modules = new LinkedList<>();
if (getApiType() == ApiType.PLUGIN) {
modules.add(env.getHttpModule());
}
@@ -279,7 +281,7 @@ public class ServerPlugin extends Plugin {
if (serverManager != null) {
if (handle instanceof ReloadableRegistrationHandle) {
if (reloadableHandles == null) {
reloadableHandles = Lists.newArrayList();
reloadableHandles = new ArrayList<>();
}
reloadableHandles.add((ReloadableRegistrationHandle<?>) handle);
}

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.project;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ActionInfo;
@@ -34,6 +33,7 @@ import com.google.gerrit.server.git.TransferConfig;
import com.google.inject.util.Providers;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -131,7 +131,7 @@ public class ConfigInfo {
this.submitType = p.getSubmitType();
this.state = p.getState() != com.google.gerrit.extensions.client.ProjectState.ACTIVE ? p.getState() : null;
this.commentlinks = Maps.newLinkedHashMap();
this.commentlinks = new LinkedHashMap<>();
for (CommentLinkInfo cl : projectState.getCommentLinks()) {
this.commentlinks.put(cl.name, cl);
}
@@ -140,7 +140,7 @@ public class ConfigInfo {
getPluginConfig(control.getProjectState(), pluginConfigEntries,
cfgFactory, allProjects);
actions = Maps.newTreeMap();
actions = new TreeMap<>();
for (UiAction.Description d : UiActions.from(
views, new ProjectResource(control),
Providers.of(control.getUser()))) {

View File

@@ -49,6 +49,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Singleton
@@ -207,7 +208,7 @@ class DashboardsCollection implements
Boolean isDefault;
String title;
List<Section> sections = Lists.newArrayList();
List<Section> sections = new ArrayList<>();
DashboardInfo(String ref, String name) {
this.ref = ref;

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.project;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
@@ -48,6 +47,7 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@Singleton
@@ -135,7 +135,7 @@ public class GetAccess implements RestReadView<ProjectResource> {
}
info.local = new HashMap<>();
info.ownerOf = Sets.newHashSet();
info.ownerOf = new HashSet<>();
Map<AccountGroup.UUID, Boolean> visibleGroups = new HashMap<>();
for (AccessSection section : config.getAccessSections()) {

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.server.project;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.common.ProjectInfo;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Project;
@@ -25,7 +23,9 @@ import com.google.inject.Inject;
import org.kohsuke.args4j.Option;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -64,7 +64,7 @@ public class ListChildProjects implements RestReadView<ProjectResource> {
}
private List<ProjectInfo> getDirectChildProjects(Project.NameKey parent) {
List<ProjectInfo> childProjects = Lists.newArrayList();
List<ProjectInfo> childProjects = new ArrayList<>();
for (Project.NameKey projectName : projectCache.all()) {
ProjectState e = projectCache.get(projectName);
if (e == null) {
@@ -80,7 +80,7 @@ public class ListChildProjects implements RestReadView<ProjectResource> {
private List<ProjectInfo> getChildProjectsRecursively(Project.NameKey parent,
CurrentUser user) {
Map<Project.NameKey, ProjectNode> projects = Maps.newHashMap();
Map<Project.NameKey, ProjectNode> projects = new HashMap<>();
for (Project.NameKey name : projectCache.all()) {
ProjectState p = projectCache.get(name);
if (p == null) {
@@ -106,7 +106,7 @@ public class ListChildProjects implements RestReadView<ProjectResource> {
}
private List<ProjectInfo> getChildProjectsRecursively(ProjectNode p) {
List<ProjectInfo> allChildren = Lists.newArrayList();
List<ProjectInfo> allChildren = new ArrayList<>();
for (ProjectNode c : p.getChildren()) {
if (c.isVisible()) {
allChildren.add(json.format(c.getProject()));

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.project;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Project;
@@ -37,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
class ListDashboards implements RestReadView<ProjectResource> {
@@ -61,7 +61,7 @@ class ListDashboards implements RestReadView<ProjectResource> {
return scan(resource.getControl(), project, true);
}
List<List<DashboardInfo>> all = Lists.newArrayList();
List<List<DashboardInfo>> all = new ArrayList<>();
boolean setDefault = true;
for (ProjectState ps : ctl.getProjectState().tree()) {
ctl = ps.controlFor(ctl.getUser());
@@ -85,7 +85,7 @@ class ListDashboards implements RestReadView<ProjectResource> {
Project.NameKey projectName = ctl.getProject().getNameKey();
try (Repository git = gitManager.openRepository(projectName);
RevWalk rw = new RevWalk(git)) {
List<DashboardInfo> all = Lists.newArrayList();
List<DashboardInfo> all = new ArrayList<>();
for (Ref ref : git.getRefDatabase().getRefs(REFS_DASHBOARDS).values()) {
if (ctl.controlForRef(ref.getName()).canRead()) {
all.addAll(scanDashboards(ctl.getProject(), git, rw, ref,
@@ -101,7 +101,7 @@ class ListDashboards implements RestReadView<ProjectResource> {
private List<DashboardInfo> scanDashboards(Project definingProject,
Repository git, RevWalk rw, Ref ref, String project, boolean setDefault)
throws IOException {
List<DashboardInfo> list = Lists.newArrayList();
List<DashboardInfo> list = new ArrayList<>();
try (TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
tw.addTree(rw.parseTree(ref.getObjectId()));
tw.setRecursive(true);

View File

@@ -21,8 +21,6 @@ import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.ProjectInfo;
@@ -61,8 +59,11 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -179,7 +180,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
this.groupUuid = groupUuid;
}
private final List<String> showBranch = Lists.newArrayList();
private final List<String> showBranch = new ArrayList<>();
private boolean showTree;
private FilterType type = FilterType.ALL;
private boolean showDescription;
@@ -256,8 +257,8 @@ public class ListProjects implements RestReadView<TopLevelResource> {
int foundIndex = 0;
int found = 0;
TreeMap<String, ProjectInfo> output = Maps.newTreeMap();
Map<String, String> hiddenNames = Maps.newHashMap();
TreeMap<String, ProjectInfo> output = new TreeMap<>();
Map<String, String> hiddenNames = new HashMap<>();
Set<String> rejected = new HashSet<>();
final TreeMap<Project.NameKey, ProjectNode> treeMap = new TreeMap<>();
@@ -357,7 +358,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
Ref ref = refs.get(i);
if (ref != null && ref.getObjectId() != null) {
if (info.branches == null) {
info.branches = Maps.newLinkedHashMap();
info.branches = new LinkedHashMap<>();
}
info.branches.put(showBranch.get(i), ref.getObjectId().name());
}

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server.project;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.api.projects.TagInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.IdString;
@@ -43,6 +42,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
import org.kohsuke.args4j.Option;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -93,7 +93,7 @@ public class ListTags implements RestReadView<ProjectResource> {
@Override
public List<TagInfo> apply(ProjectResource resource) throws IOException,
ResourceNotFoundException, BadRequestException {
List<TagInfo> tags = Lists.newArrayList();
List<TagInfo> tags = new ArrayList<>();
try (Repository repo = getRepository(resource.getNameKey());
RevWalk rw = new RevWalk(repo)) {

View File

@@ -35,6 +35,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -81,7 +82,7 @@ public class PermissionCollection {
Collection<String> usernames = null;
boolean perUser = false;
Map<AccessSection, Project.NameKey> sectionToProject = Maps.newLinkedHashMap();
Map<AccessSection, Project.NameKey> sectionToProject = new LinkedHashMap<>();
for (SectionMatcher sm : matcherList) {
// If the matcher has to expand parameters and its prefix matches the
// reference there is a very good chance the reference is actually user

View File

@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -210,7 +211,7 @@ public class ProjectCacheImpl implements ProjectCache {
@Override
public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() {
Set<AccountGroup.UUID> groups = Sets.newHashSet();
Set<AccountGroup.UUID> groups = new HashSet<>();
for (Project.NameKey n : all()) {
ProjectState p = byName.getIfPresent(n.get());
if (p != null) {

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.project;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.PageLinks;
@@ -385,7 +384,7 @@ public class ProjectControl {
}
final IdentifiedUser iUser = user.asIdentifiedUser();
List<AccountGroup.UUID> okGroupIds = Lists.newArrayList();
List<AccountGroup.UUID> okGroupIds = new ArrayList<>();
for (ContributorAgreement ca : contributorAgreements) {
List<AccountGroup.UUID> groupIds;
groupIds = okGroupIds;

View File

@@ -21,7 +21,6 @@ import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.LabelType;
@@ -61,8 +60,10 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -126,7 +127,7 @@ public class ProjectState {
this.rulesCache = rulesCache;
this.commentLinks = commentLinks;
this.config = config;
this.configs = Maps.newHashMap();
this.configs = new HashMap<>();
this.capabilities = isAllProjects
? new CapabilityCollection(config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES))
: null;
@@ -277,7 +278,7 @@ public class ProjectState {
return getLocalAccessSections();
}
List<SectionMatcher> all = Lists.newArrayList();
List<SectionMatcher> all = new ArrayList<>();
for (ProjectState s : tree()) {
all.addAll(s.getLocalAccessSections());
}
@@ -423,7 +424,7 @@ public class ProjectState {
}
public LabelTypes getLabelTypes() {
Map<String, LabelType> types = Maps.newLinkedHashMap();
Map<String, LabelType> types = new LinkedHashMap<>();
for (ProjectState s : treeInOrder()) {
for (LabelType type : s.getConfig().getLabelSections().values()) {
String lower = type.getName().toLowerCase();
@@ -443,7 +444,7 @@ public class ProjectState {
}
public List<CommentLinkInfo> getCommentLinks() {
Map<String, CommentLinkInfo> cls = Maps.newLinkedHashMap();
Map<String, CommentLinkInfo> cls = new LinkedHashMap<>();
for (CommentLinkInfo cl : commentLinks) {
cls.put(cl.name.toLowerCase(), cl);
}

Some files were not shown because too many files have changed in this diff Show More