Merge "Ensure constants are declared as immutable collections"

This commit is contained in:
Dave Borowitz
2017-03-08 18:22:19 +00:00
committed by Gerrit Code Review
7 changed files with 8 additions and 11 deletions

View File

@@ -36,7 +36,7 @@ import org.junit.Test;
@NoHttpd @NoHttpd
public class DeleteBranchesIT extends AbstractDaemonTest { public class DeleteBranchesIT extends AbstractDaemonTest {
private static final List<String> BRANCHES = private static final ImmutableList<String> BRANCHES =
ImmutableList.of("refs/heads/test-1", "refs/heads/test-2", "refs/heads/test-3"); ImmutableList.of("refs/heads/test-1", "refs/heads/test-2", "refs/heads/test-3");
@Before @Before

View File

@@ -19,7 +19,6 @@ import static java.util.concurrent.TimeUnit.MINUTES;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.gerrit.server.config.ConfigUtil; import com.google.gerrit.server.config.ConfigUtil;
import java.util.Map;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.util.CharArraySet; import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.IndexWriterConfig;
@@ -28,7 +27,7 @@ import org.eclipse.jgit.lib.Config;
/** Combination of Lucene {@link IndexWriterConfig} with additional Gerrit-specific options. */ /** Combination of Lucene {@link IndexWriterConfig} with additional Gerrit-specific options. */
class GerritIndexWriterConfig { class GerritIndexWriterConfig {
private static final Map<String, String> CUSTOM_CHAR_MAPPING = private static final ImmutableMap<String, String> CUSTOM_CHAR_MAPPING =
ImmutableMap.of("_", " ", ".", " "); ImmutableMap.of("_", " ", ".", " ");
private final IndexWriterConfig luceneConfig; private final IndexWriterConfig luceneConfig;

View File

@@ -25,7 +25,7 @@ import com.google.gerrit.server.CurrentUser;
public class AuditEvent { public class AuditEvent {
public static final String UNKNOWN_SESSION_ID = "000000000000000000000000000"; public static final String UNKNOWN_SESSION_ID = "000000000000000000000000000";
protected static final ListMultimap<String, ?> EMPTY_PARAMS = ImmutableListMultimap.of(); protected static final ImmutableListMultimap<String, ?> EMPTY_PARAMS = ImmutableListMultimap.of();
public final String sessionId; public final String sessionId;
public final CurrentUser who; public final CurrentUser who;

View File

@@ -71,7 +71,8 @@ import org.eclipse.jgit.util.RawParseUtils;
*/ */
@Singleton @Singleton
public class RulesCache { public class RulesCache {
private static final List<String> PACKAGE_LIST = ImmutableList.of(Prolog.BUILTIN, "gerrit"); private static final ImmutableList<String> PACKAGE_LIST =
ImmutableList.of(Prolog.BUILTIN, "gerrit");
private static final class MachineRef extends WeakReference<PrologMachineCopy> { private static final class MachineRef extends WeakReference<PrologMachineCopy> {
final ObjectId key; final ObjectId key;

View File

@@ -24,7 +24,6 @@ import static org.eclipse.jgit.lib.ObjectIdSerialization.writeNotNull;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.Weigher; import com.google.common.cache.Weigher;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.client.SubmitType;
@@ -61,7 +60,7 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
private static final String CACHE_NAME = "mergeability"; private static final String CACHE_NAME = "mergeability";
public static final BiMap<SubmitType, Character> SUBMIT_TYPES = public static final ImmutableBiMap<SubmitType, Character> SUBMIT_TYPES =
new ImmutableBiMap.Builder<SubmitType, Character>() new ImmutableBiMap.Builder<SubmitType, Character>()
.put(SubmitType.FAST_FORWARD_ONLY, 'F') .put(SubmitType.FAST_FORWARD_ONLY, 'F')
.put(SubmitType.MERGE_IF_NECESSARY, 'M') .put(SubmitType.MERGE_IF_NECESSARY, 'M')

View File

@@ -20,7 +20,6 @@ import static org.eclipse.jgit.lib.ObjectIdSerialization.readNotNull;
import static org.eclipse.jgit.lib.ObjectIdSerialization.writeCanBeNull; import static org.eclipse.jgit.lib.ObjectIdSerialization.writeCanBeNull;
import static org.eclipse.jgit.lib.ObjectIdSerialization.writeNotNull; import static org.eclipse.jgit.lib.ObjectIdSerialization.writeNotNull;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
@@ -35,7 +34,7 @@ import org.eclipse.jgit.lib.ObjectId;
public class PatchListKey implements Serializable { public class PatchListKey implements Serializable {
public static final long serialVersionUID = 24L; public static final long serialVersionUID = 24L;
public static final BiMap<Whitespace, Character> WHITESPACE_TYPES = public static final ImmutableBiMap<Whitespace, Character> WHITESPACE_TYPES =
ImmutableBiMap.of( ImmutableBiMap.of(
Whitespace.IGNORE_NONE, 'N', Whitespace.IGNORE_NONE, 'N',
Whitespace.IGNORE_TRAILING, 'E', Whitespace.IGNORE_TRAILING, 'E',

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.project; package com.google.gerrit.server.project;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
@@ -51,7 +50,7 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
@Singleton @Singleton
public class GetAccess implements RestReadView<ProjectResource> { public class GetAccess implements RestReadView<ProjectResource> {
public static final BiMap<PermissionRule.Action, PermissionRuleInfo.Action> ACTION_TYPE = public static final ImmutableBiMap<PermissionRule.Action, PermissionRuleInfo.Action> ACTION_TYPE =
ImmutableBiMap.of( ImmutableBiMap.of(
PermissionRule.Action.ALLOW, PermissionRule.Action.ALLOW,
PermissionRuleInfo.Action.ALLOW, PermissionRuleInfo.Action.ALLOW,