Ensure constants are declared as immutable collections
This communicates important semantic guarantees to callers, as described in the ImmutableCollection javadoc. It also makes calls to mutating methods result in compiler warnings. PiperOrigin-RevId: 149238269 PiperOrigin-RevId: 148972127 PiperOrigin-RevId: 149233478 PiperOrigin-RevId: 149235768 Change-Id: I6d3de40810c83aaa258c6b93a24a3f9fd18994e8
This commit is contained in:
parent
48e08d7776
commit
99cd8121ea
|
@ -36,7 +36,7 @@ import org.junit.Test;
|
|||
|
||||
@NoHttpd
|
||||
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");
|
||||
|
||||
@Before
|
||||
|
|
|
@ -19,7 +19,6 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import java.util.Map;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.analysis.util.CharArraySet;
|
||||
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. */
|
||||
class GerritIndexWriterConfig {
|
||||
private static final Map<String, String> CUSTOM_CHAR_MAPPING =
|
||||
private static final ImmutableMap<String, String> CUSTOM_CHAR_MAPPING =
|
||||
ImmutableMap.of("_", " ", ".", " ");
|
||||
|
||||
private final IndexWriterConfig luceneConfig;
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.gerrit.server.CurrentUser;
|
|||
public class AuditEvent {
|
||||
|
||||
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 CurrentUser who;
|
||||
|
|
|
@ -71,7 +71,8 @@ import org.eclipse.jgit.util.RawParseUtils;
|
|||
*/
|
||||
@Singleton
|
||||
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> {
|
||||
final ObjectId key;
|
||||
|
|
|
@ -24,7 +24,6 @@ import static org.eclipse.jgit.lib.ObjectIdSerialization.writeNotNull;
|
|||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.Weigher;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
|
@ -61,7 +60,7 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
|
|||
|
||||
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>()
|
||||
.put(SubmitType.FAST_FORWARD_ONLY, 'F')
|
||||
.put(SubmitType.MERGE_IF_NECESSARY, 'M')
|
||||
|
|
|
@ -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.writeNotNull;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
|
||||
|
@ -35,7 +34,7 @@ import org.eclipse.jgit.lib.ObjectId;
|
|||
public class PatchListKey implements Serializable {
|
||||
public static final long serialVersionUID = 24L;
|
||||
|
||||
public static final BiMap<Whitespace, Character> WHITESPACE_TYPES =
|
||||
public static final ImmutableBiMap<Whitespace, Character> WHITESPACE_TYPES =
|
||||
ImmutableBiMap.of(
|
||||
Whitespace.IGNORE_NONE, 'N',
|
||||
Whitespace.IGNORE_TRAILING, 'E',
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
|
@ -51,7 +50,7 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
|||
@Singleton
|
||||
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(
|
||||
PermissionRule.Action.ALLOW,
|
||||
PermissionRuleInfo.Action.ALLOW,
|
||||
|
|
Loading…
Reference in New Issue