Make IndexConfig an @AutoValue

Change-Id: I89333aad9501f1cd49061f85b104a4c6d858e4f3
This commit is contained in:
Dave Borowitz
2015-01-20 11:40:12 -08:00
parent a1b4bacdbd
commit 0df53ffac7
2 changed files with 9 additions and 10 deletions

View File

@@ -16,6 +16,8 @@ package com.google.gerrit.server.index;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.auto.value.AutoValue;
/**
* Implementation-specific configuration for secondary indexes.
* <p>
@@ -23,19 +25,16 @@ import static com.google.common.base.Preconditions.checkArgument;
* otherwise global, i.e. not tied to a specific {@link ChangeIndex} and schema
* version.
*/
public class IndexConfig {
@AutoValue
public abstract class IndexConfig {
public static IndexConfig createDefault() {
return new IndexConfig(Integer.MAX_VALUE);
return create(Integer.MAX_VALUE);
}
private final int maxLimit;
public IndexConfig(int maxLimit) {
public static IndexConfig create(int maxLimit) {
checkArgument(maxLimit > 0, "maxLimit must be positive: %s", maxLimit);
this.maxLimit = maxLimit;
return new AutoValue_IndexConfig(maxLimit);
}
public int getMaxLimit() {
return maxLimit;
}
public abstract int maxLimit();
}

View File

@@ -178,7 +178,7 @@ public class QueryProcessor {
}
private int getBackendSupportedLimit() {
return indexConfig.getMaxLimit();
return indexConfig.maxLimit();
}
private int getEffectiveLimit(Predicate<ChangeData> p) {