Make Predicates more amenable to use by plugins

Make most Predicates and static methods public, make most private
fields and methods protected.

Change-Id: Id898e835341765d8d0d86ed7dcb3a21ea4c8ef27
This commit is contained in:
Nasser Grainawi
2017-04-10 22:22:15 -06:00
parent 21a3426c94
commit aeb3db043c
55 changed files with 203 additions and 202 deletions

View File

@@ -18,10 +18,10 @@ import java.util.Collection;
/** Predicate to filter a field by matching value. */
public abstract class OperatorPredicate<T> extends Predicate<T> {
private final String name;
private final String value;
protected final String name;
protected final String value;
protected OperatorPredicate(final String name, final String value) {
public OperatorPredicate(final String name, final String value) {
this.name = name;
this.value = value;
}

View File

@@ -20,9 +20,9 @@ import com.google.gerrit.server.query.IsVisibleToPredicate;
import com.google.gwtorm.server.OrmException;
public class AccountIsVisibleToPredicate extends IsVisibleToPredicate<AccountState> {
private final AccountControl accountControl;
protected final AccountControl accountControl;
AccountIsVisibleToPredicate(AccountControl accountControl) {
public AccountIsVisibleToPredicate(AccountControl accountControl) {
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(accountControl.getUser()));
this.accountControl = accountControl;
}

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
public class AddedPredicate extends IntegerRangeChangePredicate {
AddedPredicate(String value) throws QueryParseException {
public AddedPredicate(String value) throws QueryParseException {
super(ChangeField.ADDED, value);
}

View File

@@ -20,9 +20,9 @@ import com.google.gwtorm.server.OrmException;
import java.util.Date;
public class AfterPredicate extends TimestampRangeChangePredicate {
private final Date cut;
protected final Date cut;
AfterPredicate(String value) throws QueryParseException {
public AfterPredicate(String value) throws QueryParseException {
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
cut = parse(value);
}

View File

@@ -25,9 +25,9 @@ import com.google.gwtorm.server.OrmException;
import java.sql.Timestamp;
public class AgePredicate extends TimestampRangeChangePredicate {
private final long cut;
protected final long cut;
AgePredicate(String value) {
public AgePredicate(String value) {
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_AGE, value);
long s = ConfigUtil.getTimeUnit(getValue(), 0, SECONDS);

View File

@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class AssigneePredicate extends ChangeIndexPredicate {
private final Account.Id id;
public class AssigneePredicate extends ChangeIndexPredicate {
protected final Account.Id id;
AssigneePredicate(Account.Id id) {
public AssigneePredicate(Account.Id id) {
super(ChangeField.ASSIGNEE, id.toString());
this.id = id;
}

View File

@@ -22,7 +22,7 @@ import com.google.gwtorm.server.OrmException;
import java.io.IOException;
public class AuthorPredicate extends ChangeIndexPredicate {
AuthorPredicate(String value) {
public AuthorPredicate(String value) {
super(AUTHOR, FIELD_AUTHOR, value.toLowerCase());
}

View File

@@ -20,9 +20,9 @@ import com.google.gwtorm.server.OrmException;
import java.util.Date;
public class BeforePredicate extends TimestampRangeChangePredicate {
private final Date cut;
protected final Date cut;
BeforePredicate(String value) throws QueryParseException {
public BeforePredicate(String value) throws QueryParseException {
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
cut = parse(value);
}

View File

@@ -18,10 +18,10 @@ import com.google.gerrit.server.index.FieldDef;
import com.google.gerrit.server.index.FieldDef.FillArgs;
import com.google.gwtorm.server.OrmException;
class BooleanPredicate extends ChangeIndexPredicate {
private final FillArgs args;
public class BooleanPredicate extends ChangeIndexPredicate {
protected final FillArgs args;
BooleanPredicate(FieldDef<ChangeData, String> field, FillArgs args) {
public BooleanPredicate(FieldDef<ChangeData, String> field, FillArgs args) {
super(field, "1");
this.args = args;
}

View File

@@ -19,8 +19,8 @@ import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
/** Predicate over Change-Id strings (aka Change.Key). */
class ChangeIdPredicate extends ChangeIndexPredicate {
ChangeIdPredicate(String id) {
public class ChangeIdPredicate extends ChangeIndexPredicate {
public ChangeIdPredicate(String id) {
super(ChangeField.ID, ChangeQueryBuilder.FIELD_CHANGE, id);
}

View File

@@ -24,13 +24,13 @@ import com.google.gerrit.server.query.IsVisibleToPredicate;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Provider;
class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData> {
private final Provider<ReviewDb> db;
private final ChangeNotes.Factory notesFactory;
private final ChangeControl.GenericFactory changeControl;
private final CurrentUser user;
public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData> {
protected final Provider<ReviewDb> db;
protected final ChangeNotes.Factory notesFactory;
protected final ChangeControl.GenericFactory changeControl;
protected final CurrentUser user;
ChangeIsVisibleToPredicate(
public ChangeIsVisibleToPredicate(
Provider<ReviewDb> db,
ChangeNotes.Factory notesFactory,
ChangeControl.GenericFactory changeControlFactory,

View File

@@ -36,9 +36,9 @@ import java.util.TreeMap;
* <p>Status names are looked up by prefix case-insensitively.
*/
public final class ChangeStatusPredicate extends ChangeIndexPredicate {
private static final TreeMap<String, Predicate<ChangeData>> PREDICATES;
private static final Predicate<ChangeData> CLOSED;
private static final Predicate<ChangeData> OPEN;
protected static final TreeMap<String, Predicate<ChangeData>> PREDICATES;
protected static final Predicate<ChangeData> CLOSED;
protected static final Predicate<ChangeData> OPEN;
static {
PREDICATES = new TreeMap<>();
@@ -84,9 +84,9 @@ public final class ChangeStatusPredicate extends ChangeIndexPredicate {
return CLOSED;
}
private final Change.Status status;
protected final Change.Status status;
ChangeStatusPredicate(Change.Status status) {
public ChangeStatusPredicate(Change.Status status) {
super(ChangeField.STATUS, canonicalize(status));
this.status = status;
}

View File

@@ -21,10 +21,10 @@ import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
import java.util.Objects;
class CommentByPredicate extends ChangeIndexPredicate {
private final Account.Id id;
public class CommentByPredicate extends ChangeIndexPredicate {
protected final Account.Id id;
CommentByPredicate(Account.Id id) {
public CommentByPredicate(Account.Id id) {
super(ChangeField.COMMENTBY, id.toString());
this.id = id;
}

View File

@@ -21,10 +21,10 @@ import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
class CommentPredicate extends ChangeIndexPredicate {
private final ChangeIndex index;
public class CommentPredicate extends ChangeIndexPredicate {
protected final ChangeIndex index;
CommentPredicate(ChangeIndex index, String value) {
public CommentPredicate(ChangeIndex index, String value) {
super(ChangeField.COMMENT, value);
this.index = index;
}

View File

@@ -22,7 +22,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.index.FieldDef;
import com.google.gwtorm.server.OrmException;
class CommitPredicate extends ChangeIndexPredicate {
public class CommitPredicate extends ChangeIndexPredicate {
static FieldDef<ChangeData, ?> commitField(String id) {
if (id.length() == OBJECT_ID_STRING_LENGTH) {
return EXACT_COMMIT;
@@ -30,7 +30,7 @@ class CommitPredicate extends ChangeIndexPredicate {
return COMMIT;
}
CommitPredicate(String id) {
public CommitPredicate(String id) {
super(commitField(id), id);
}
@@ -45,7 +45,7 @@ class CommitPredicate extends ChangeIndexPredicate {
return false;
}
private boolean equals(PatchSet p, String id) {
protected boolean equals(PatchSet p, String id) {
boolean exact = getField() == EXACT_COMMIT;
String rev = p.getRevision() != null ? p.getRevision().get() : null;
return (exact && id.equals(rev)) || (!exact && rev != null && rev.startsWith(id));

View File

@@ -22,7 +22,7 @@ import com.google.gwtorm.server.OrmException;
import java.io.IOException;
public class CommitterPredicate extends ChangeIndexPredicate {
CommitterPredicate(String value) {
public CommitterPredicate(String value) {
super(COMMITTER, FIELD_COMMITTER, value.toLowerCase());
}

View File

@@ -45,19 +45,19 @@ import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
class ConflictsPredicate extends OrPredicate<ChangeData> {
public class ConflictsPredicate extends OrPredicate<ChangeData> {
// UI code may depend on this string, so use caution when changing.
private static final String TOO_MANY_FILES = "too many files to find conflicts";
protected static final String TOO_MANY_FILES = "too many files to find conflicts";
private final String value;
protected final String value;
ConflictsPredicate(Arguments args, String value, List<Change> changes)
public ConflictsPredicate(Arguments args, String value, List<Change> changes)
throws QueryParseException, OrmException {
super(predicates(args, value, changes));
this.value = value;
}
private static List<Predicate<ChangeData>> predicates(
public static List<Predicate<ChangeData>> predicates(
final Arguments args, String value, List<Change> changes)
throws QueryParseException, OrmException {
int indexTerms = 0;
@@ -160,7 +160,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
return changePredicates;
}
private static List<String> listFiles(Change c, Arguments args, ChangeDataCache changeDataCache)
public static List<String> listFiles(Change c, Arguments args, ChangeDataCache changeDataCache)
throws OrmException {
try (Repository repo = args.repoManager.openRepository(c.getProject());
RevWalk rw = new RevWalk(repo)) {
@@ -200,17 +200,17 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
return ChangeQueryBuilder.FIELD_CONFLICTS + ":" + value;
}
private static class ChangeDataCache {
private final Change change;
private final Provider<ReviewDb> db;
private final ChangeData.Factory changeDataFactory;
private final ProjectCache projectCache;
public static class ChangeDataCache {
protected final Change change;
protected final Provider<ReviewDb> db;
protected final ChangeData.Factory changeDataFactory;
protected final ProjectCache projectCache;
private ObjectId testAgainst;
private ProjectState projectState;
private Iterable<ObjectId> alreadyAccepted;
protected ObjectId testAgainst;
protected ProjectState projectState;
protected Iterable<ObjectId> alreadyAccepted;
ChangeDataCache(
public ChangeDataCache(
Change change,
Provider<ReviewDb> db,
ChangeData.Factory changeDataFactory,
@@ -221,7 +221,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
this.projectCache = projectCache;
}
ObjectId getTestAgainst() throws OrmException {
protected ObjectId getTestAgainst() throws OrmException {
if (testAgainst == null) {
testAgainst =
ObjectId.fromString(
@@ -230,7 +230,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
return testAgainst;
}
ProjectState getProjectState() {
protected ProjectState getProjectState() {
if (projectState == null) {
projectState = projectCache.get(change.getProject());
if (projectState == null) {
@@ -240,7 +240,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
return projectState;
}
Iterable<ObjectId> getAlreadyAccepted(Repository repo) throws IOException {
protected Iterable<ObjectId> getAlreadyAccepted(Repository repo) throws IOException {
if (alreadyAccepted == null) {
alreadyAccepted = SubmitDryRun.getAlreadyAccepted(repo);
}

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
public class DeletedPredicate extends IntegerRangeChangePredicate {
DeletedPredicate(String value) throws QueryParseException {
public DeletedPredicate(String value) throws QueryParseException {
super(ChangeField.DELETED, value);
}

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
public class DeltaPredicate extends IntegerRangeChangePredicate {
DeltaPredicate(String value) throws QueryParseException {
public DeltaPredicate(String value) throws QueryParseException {
super(ChangeField.DELTA, value);
}

View File

@@ -19,10 +19,10 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gwtorm.server.OrmException;
import java.util.Set;
class DestinationPredicate extends ChangeOperatorPredicate {
Set<Branch.NameKey> destinations;
public class DestinationPredicate extends ChangeOperatorPredicate {
protected Set<Branch.NameKey> destinations;
DestinationPredicate(Set<Branch.NameKey> destinations, String value) {
public DestinationPredicate(Set<Branch.NameKey> destinations, String value) {
super(ChangeQueryBuilder.FIELD_DESTINATION, value);
this.destinations = destinations;
}

View File

@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class EditByPredicate extends ChangeIndexPredicate {
private final Account.Id id;
public class EditByPredicate extends ChangeIndexPredicate {
protected final Account.Id id;
EditByPredicate(Account.Id id) {
public EditByPredicate(Account.Id id) {
super(ChangeField.EDITBY, id.toString());
this.id = id;
}

View File

@@ -19,8 +19,8 @@ import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
import com.google.gwtorm.server.OrmException;
class EqualsFilePredicate extends ChangeIndexPredicate {
static Predicate<ChangeData> create(Arguments args, String value) {
public class EqualsFilePredicate extends ChangeIndexPredicate {
public static Predicate<ChangeData> create(Arguments args, String value) {
Predicate<ChangeData> eqPath = new EqualsPathPredicate(ChangeQueryBuilder.FIELD_FILE, value);
if (!args.getSchema().hasField(ChangeField.FILE_PART)) {
return eqPath;
@@ -28,7 +28,7 @@ class EqualsFilePredicate extends ChangeIndexPredicate {
return Predicate.or(eqPath, new EqualsFilePredicate(value));
}
private final String value;
protected final String value;
private EqualsFilePredicate(String value) {
super(ChangeField.FILE_PART, ChangeQueryBuilder.FIELD_FILE, value);

View File

@@ -31,17 +31,18 @@ import com.google.gerrit.server.project.ProjectState;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Provider;
class EqualsLabelPredicate extends ChangeIndexPredicate {
private final ProjectCache projectCache;
private final PermissionBackend permissionBackend;
private final IdentifiedUser.GenericFactory userFactory;
private final Provider<ReviewDb> dbProvider;
private final String label;
private final int expVal;
private final Account.Id account;
private final AccountGroup.UUID group;
public class EqualsLabelPredicate extends ChangeIndexPredicate {
protected final ProjectCache projectCache;
protected final PermissionBackend permissionBackend;
protected final IdentifiedUser.GenericFactory userFactory;
protected final Provider<ReviewDb> dbProvider;
protected final String label;
protected final int expVal;
protected final Account.Id account;
protected final AccountGroup.UUID group;
EqualsLabelPredicate(LabelPredicate.Args args, String label, int expVal, Account.Id account) {
public EqualsLabelPredicate(
LabelPredicate.Args args, String label, int expVal, Account.Id account) {
super(ChangeField.LABEL, ChangeField.formatLabel(label, expVal, account));
this.permissionBackend = args.permissionBackend;
this.projectCache = args.projectCache;
@@ -91,7 +92,7 @@ class EqualsLabelPredicate extends ChangeIndexPredicate {
return false;
}
private static LabelType type(LabelTypes types, String toFind) {
protected static LabelType type(LabelTypes types, String toFind) {
if (types.byLabel(toFind) != null) {
return types.byLabel(toFind);
}
@@ -104,7 +105,7 @@ class EqualsLabelPredicate extends ChangeIndexPredicate {
return null;
}
private boolean match(ChangeData cd, short value, Account.Id approver, LabelType type) {
protected boolean match(ChangeData cd, short value, Account.Id approver, LabelType type) {
if (value != expVal) {
return false;
}

View File

@@ -19,10 +19,10 @@ import com.google.gwtorm.server.OrmException;
import java.util.Collections;
import java.util.List;
class EqualsPathPredicate extends ChangeIndexPredicate {
private final String value;
public class EqualsPathPredicate extends ChangeIndexPredicate {
protected final String value;
EqualsPathPredicate(String fieldName, String value) {
public EqualsPathPredicate(String fieldName, String value) {
super(ChangeField.PATH, fieldName, value);
this.value = value;
}

View File

@@ -19,8 +19,8 @@ import static com.google.gerrit.server.index.change.ChangeField.EXACT_TOPIC;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gwtorm.server.OrmException;
class ExactTopicPredicate extends ChangeIndexPredicate {
ExactTopicPredicate(String topic) {
public class ExactTopicPredicate extends ChangeIndexPredicate {
public ExactTopicPredicate(String topic) {
super(EXACT_TOPIC, topic);
}

View File

@@ -24,10 +24,10 @@ import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
class FuzzyTopicPredicate extends ChangeIndexPredicate {
private final ChangeIndex index;
public class FuzzyTopicPredicate extends ChangeIndexPredicate {
protected final ChangeIndex index;
FuzzyTopicPredicate(String topic, ChangeIndex index) {
public FuzzyTopicPredicate(String topic, ChangeIndex index) {
super(FUZZY_TOPIC, topic);
this.index = index;
}

View File

@@ -19,8 +19,8 @@ import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
import java.util.List;
class GroupPredicate extends ChangeIndexPredicate {
GroupPredicate(String group) {
public class GroupPredicate extends ChangeIndexPredicate {
public GroupPredicate(String group) {
super(ChangeField.GROUP, group);
}

View File

@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class HasDraftByPredicate extends ChangeIndexPredicate {
private final Account.Id accountId;
public class HasDraftByPredicate extends ChangeIndexPredicate {
protected final Account.Id accountId;
HasDraftByPredicate(Account.Id accountId) {
public HasDraftByPredicate(Account.Id accountId) {
super(ChangeField.DRAFTBY, accountId.toString());
this.accountId = accountId;
}

View File

@@ -19,9 +19,9 @@ import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
public class HasStarsPredicate extends ChangeIndexPredicate {
private final Account.Id accountId;
protected final Account.Id accountId;
HasStarsPredicate(Account.Id accountId) {
public HasStarsPredicate(Account.Id accountId) {
super(ChangeField.STARBY, accountId.toString());
this.accountId = accountId;
}

View File

@@ -18,8 +18,8 @@ import com.google.gerrit.server.change.HashtagsUtil;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class HashtagPredicate extends ChangeIndexPredicate {
HashtagPredicate(String hashtag) {
public class HashtagPredicate extends ChangeIndexPredicate {
public HashtagPredicate(String hashtag) {
super(ChangeField.HASHTAG, HashtagsUtil.cleanupHashtag(hashtag));
}

View File

@@ -24,7 +24,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
public class IsMergePredicate extends ChangeOperatorPredicate {
private final Arguments args;
protected final Arguments args;
public IsMergePredicate(Arguments args, String value) {
super(ChangeQueryBuilder.FIELD_MERGE, value);

View File

@@ -25,14 +25,14 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
class IsReviewedPredicate extends ChangeIndexPredicate {
private static final Account.Id NOT_REVIEWED = new Account.Id(ChangeField.NOT_REVIEWED);
public class IsReviewedPredicate extends ChangeIndexPredicate {
protected static final Account.Id NOT_REVIEWED = new Account.Id(ChangeField.NOT_REVIEWED);
static Predicate<ChangeData> create() {
public static Predicate<ChangeData> create() {
return Predicate.not(new IsReviewedPredicate(NOT_REVIEWED));
}
static Predicate<ChangeData> create(Collection<Account.Id> ids) {
public static Predicate<ChangeData> create(Collection<Account.Id> ids) {
List<Predicate<ChangeData>> predicates = new ArrayList<>(ids.size());
for (Account.Id id : ids) {
predicates.add(new IsReviewedPredicate(id));
@@ -40,7 +40,7 @@ class IsReviewedPredicate extends ChangeIndexPredicate {
return Predicate.or(predicates);
}
private final Account.Id id;
protected final Account.Id id;
private IsReviewedPredicate(Account.Id id) {
super(REVIEWEDBY, Integer.toString(id.get()));

View File

@@ -19,11 +19,11 @@ import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
public class IsUnresolvedPredicate extends IntegerRangeChangePredicate {
IsUnresolvedPredicate() throws QueryParseException {
public IsUnresolvedPredicate() throws QueryParseException {
this(">0");
}
IsUnresolvedPredicate(String value) throws QueryParseException {
public IsUnresolvedPredicate(String value) throws QueryParseException {
super(ChangeField.UNRESOLVED_COMMENT_COUNT, value);
}

View File

@@ -26,23 +26,23 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
class IsWatchedByPredicate extends AndPredicate<ChangeData> {
private static String describe(CurrentUser user) {
public class IsWatchedByPredicate extends AndPredicate<ChangeData> {
protected static String describe(CurrentUser user) {
if (user.isIdentifiedUser()) {
return user.getAccountId().toString();
}
return user.toString();
}
private final CurrentUser user;
protected final CurrentUser user;
IsWatchedByPredicate(ChangeQueryBuilder.Arguments args, boolean checkIsVisible)
public IsWatchedByPredicate(ChangeQueryBuilder.Arguments args, boolean checkIsVisible)
throws QueryParseException {
super(filters(args, checkIsVisible));
this.user = args.getUser();
}
private static List<Predicate<ChangeData>> filters(
protected static List<Predicate<ChangeData>> filters(
ChangeQueryBuilder.Arguments args, boolean checkIsVisible) throws QueryParseException {
List<Predicate<ChangeData>> r = new ArrayList<>();
ChangeQueryBuilder builder = new ChangeQueryBuilder(args);
@@ -89,7 +89,7 @@ class IsWatchedByPredicate extends AndPredicate<ChangeData> {
}
}
private static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
protected static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
throws QueryParseException {
CurrentUser user = args.getUser();
if (user.isIdentifiedUser()) {
@@ -98,7 +98,7 @@ class IsWatchedByPredicate extends AndPredicate<ChangeData> {
return Collections.<ProjectWatchKey>emptySet();
}
private static List<Predicate<ChangeData>> none() {
protected static List<Predicate<ChangeData>> none() {
Predicate<ChangeData> any = any();
return ImmutableList.of(not(any));
}

View File

@@ -33,19 +33,19 @@ import java.util.List;
import java.util.Set;
public class LabelPredicate extends OrPredicate<ChangeData> {
private static final int MAX_LABEL_VALUE = 4;
protected static final int MAX_LABEL_VALUE = 4;
static class Args {
final ProjectCache projectCache;
final PermissionBackend permissionBackend;
final ChangeControl.GenericFactory ccFactory;
final IdentifiedUser.GenericFactory userFactory;
final Provider<ReviewDb> dbProvider;
final String value;
final Set<Account.Id> accounts;
final AccountGroup.UUID group;
protected static class Args {
protected final ProjectCache projectCache;
protected final PermissionBackend permissionBackend;
protected final ChangeControl.GenericFactory ccFactory;
protected final IdentifiedUser.GenericFactory userFactory;
protected final Provider<ReviewDb> dbProvider;
protected final String value;
protected final Set<Account.Id> accounts;
protected final AccountGroup.UUID group;
private Args(
protected Args(
ProjectCache projectCache,
PermissionBackend permissionBackend,
ChangeControl.GenericFactory ccFactory,
@@ -65,21 +65,21 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
}
}
private static class Parsed {
private final String label;
private final String test;
private final int expVal;
protected static class Parsed {
protected final String label;
protected final String test;
protected final int expVal;
private Parsed(String label, String test, int expVal) {
protected Parsed(String label, String test, int expVal) {
this.label = label;
this.test = test;
this.expVal = expVal;
}
}
private final String value;
protected final String value;
LabelPredicate(
public LabelPredicate(
ChangeQueryBuilder.Arguments a,
String value,
Set<Account.Id> accounts,
@@ -98,7 +98,7 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
this.value = value;
}
private static List<Predicate<ChangeData>> predicates(Args args) {
protected static List<Predicate<ChangeData>> predicates(Args args) {
String v = args.value;
Parsed parsed = null;
@@ -138,14 +138,14 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
return r;
}
private static Predicate<ChangeData> onePredicate(Args args, String label, int expVal) {
protected static Predicate<ChangeData> onePredicate(Args args, String label, int expVal) {
if (expVal != 0) {
return equalsLabelPredicate(args, label, expVal);
}
return noLabelQuery(args, label);
}
private static Predicate<ChangeData> noLabelQuery(Args args, String label) {
protected static Predicate<ChangeData> noLabelQuery(Args args, String label) {
List<Predicate<ChangeData>> r = Lists.newArrayListWithCapacity(2 * MAX_LABEL_VALUE);
for (int i = 1; i <= MAX_LABEL_VALUE; i++) {
r.add(equalsLabelPredicate(args, label, i));
@@ -154,7 +154,7 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
return not(or(r));
}
private static Predicate<ChangeData> equalsLabelPredicate(Args args, String label, int expVal) {
protected static Predicate<ChangeData> equalsLabelPredicate(Args args, String label, int expVal) {
if (args.accounts == null || args.accounts.isEmpty()) {
return new EqualsLabelPredicate(args, label, expVal, null);
}

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.reviewdb.client.Change;
/** Predicate over change number (aka legacy ID or Change.Id). */
public class LegacyChangeIdPredicate extends ChangeIndexPredicate {
private final Change.Id id;
protected final Change.Id id;
public LegacyChangeIdPredicate(Change.Id id) {
super(LEGACY_ID, ChangeQueryBuilder.FIELD_CHANGE, id.toString());

View File

@@ -22,10 +22,10 @@ import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
/** Predicate to match changes that contains specified text in commit messages body. */
class MessagePredicate extends ChangeIndexPredicate {
private final ChangeIndex index;
public class MessagePredicate extends ChangeIndexPredicate {
protected final ChangeIndex index;
MessagePredicate(ChangeIndex index, String value) {
public MessagePredicate(ChangeIndex index, String value) {
super(ChangeField.COMMIT_MESSAGE, value);
this.index = index;
}

View File

@@ -19,15 +19,15 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class OwnerPredicate extends ChangeIndexPredicate {
private final Account.Id id;
public class OwnerPredicate extends ChangeIndexPredicate {
protected final Account.Id id;
OwnerPredicate(Account.Id id) {
public OwnerPredicate(Account.Id id) {
super(ChangeField.OWNER, id.toString());
this.id = id;
}
Account.Id getAccountId() {
protected Account.Id getAccountId() {
return id;
}

View File

@@ -19,17 +19,17 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gwtorm.server.OrmException;
class OwnerinPredicate extends ChangeOperatorPredicate {
private final IdentifiedUser.GenericFactory userFactory;
private final AccountGroup.UUID uuid;
public class OwnerinPredicate extends ChangeOperatorPredicate {
protected final IdentifiedUser.GenericFactory userFactory;
protected final AccountGroup.UUID uuid;
OwnerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
public OwnerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
super(ChangeQueryBuilder.FIELD_OWNERIN, uuid.toString());
this.userFactory = userFactory;
this.uuid = uuid;
}
AccountGroup.UUID getAccountGroupUUID() {
protected AccountGroup.UUID getAccountGroupUUID() {
return uuid;
}

View File

@@ -28,10 +28,10 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class ParentProjectPredicate extends OrPredicate<ChangeData> {
private final String value;
public class ParentProjectPredicate extends OrPredicate<ChangeData> {
protected final String value;
ParentProjectPredicate(
public ParentProjectPredicate(
ProjectCache projectCache,
Provider<ListChildProjects> listChildProjects,
Provider<CurrentUser> self,
@@ -40,7 +40,7 @@ class ParentProjectPredicate extends OrPredicate<ChangeData> {
this.value = value;
}
private static List<Predicate<ChangeData>> predicates(
protected static List<Predicate<ChangeData>> predicates(
ProjectCache projectCache,
Provider<ListChildProjects> listChildProjects,
Provider<CurrentUser> self,

View File

@@ -19,12 +19,12 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class ProjectPredicate extends ChangeIndexPredicate {
ProjectPredicate(String id) {
public class ProjectPredicate extends ChangeIndexPredicate {
public ProjectPredicate(String id) {
super(ChangeField.PROJECT, id);
}
Project.NameKey getValueKey() {
protected Project.NameKey getValueKey() {
return new Project.NameKey(getValue());
}

View File

@@ -18,8 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class ProjectPrefixPredicate extends ChangeIndexPredicate {
ProjectPrefixPredicate(String prefix) {
public class ProjectPrefixPredicate extends ChangeIndexPredicate {
public ProjectPrefixPredicate(String prefix) {
super(ChangeField.PROJECTS, prefix);
}

View File

@@ -18,8 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class RefPredicate extends ChangeIndexPredicate {
RefPredicate(String ref) {
public class RefPredicate extends ChangeIndexPredicate {
public RefPredicate(String ref) {
super(ChangeField.REF, ref);
}

View File

@@ -19,8 +19,8 @@ import com.google.gerrit.server.util.RegexListSearcher;
import com.google.gwtorm.server.OrmException;
import java.util.List;
class RegexPathPredicate extends ChangeRegexPredicate {
RegexPathPredicate(String re) {
public class RegexPathPredicate extends ChangeRegexPredicate {
public RegexPathPredicate(String re) {
super(ChangeField.PATH, re);
}

View File

@@ -21,10 +21,10 @@ import com.google.gwtorm.server.OrmException;
import dk.brics.automaton.RegExp;
import dk.brics.automaton.RunAutomaton;
class RegexProjectPredicate extends ChangeRegexPredicate {
private final RunAutomaton pattern;
public class RegexProjectPredicate extends ChangeRegexPredicate {
protected final RunAutomaton pattern;
RegexProjectPredicate(String re) {
public RegexProjectPredicate(String re) {
super(ChangeField.PROJECT, re);
if (re.startsWith("^")) {

View File

@@ -20,10 +20,10 @@ import com.google.gwtorm.server.OrmException;
import dk.brics.automaton.RegExp;
import dk.brics.automaton.RunAutomaton;
class RegexRefPredicate extends ChangeRegexPredicate {
private final RunAutomaton pattern;
public class RegexRefPredicate extends ChangeRegexPredicate {
protected final RunAutomaton pattern;
RegexRefPredicate(String re) {
public RegexRefPredicate(String re) {
super(ChangeField.REF, re);
if (re.startsWith("^")) {

View File

@@ -21,10 +21,10 @@ import com.google.gwtorm.server.OrmException;
import dk.brics.automaton.RegExp;
import dk.brics.automaton.RunAutomaton;
class RegexTopicPredicate extends ChangeRegexPredicate {
private final RunAutomaton pattern;
public class RegexTopicPredicate extends ChangeRegexPredicate {
protected final RunAutomaton pattern;
RegexTopicPredicate(String re) {
public RegexTopicPredicate(String re) {
super(EXACT_TOPIC, re);
if (re.startsWith("^")) {

View File

@@ -25,14 +25,14 @@ import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
import com.google.gwtorm.server.OrmException;
import java.util.stream.Stream;
class ReviewerPredicate extends ChangeIndexPredicate {
static Predicate<ChangeData> forState(
public class ReviewerPredicate extends ChangeIndexPredicate {
protected static Predicate<ChangeData> forState(
Arguments args, Account.Id id, ReviewerStateInternal state) {
checkArgument(state != ReviewerStateInternal.REMOVED, "can't query by removed reviewer");
return create(args, new ReviewerPredicate(state, id));
}
static Predicate<ChangeData> reviewer(Arguments args, Account.Id id) {
protected static Predicate<ChangeData> reviewer(Arguments args, Account.Id id) {
Predicate<ChangeData> p;
if (args.notesMigration.readChanges()) {
// With NoteDb, Reviewer/CC are clearly distinct states, so only choose reviewer.
@@ -45,14 +45,14 @@ class ReviewerPredicate extends ChangeIndexPredicate {
return create(args, p);
}
static Predicate<ChangeData> cc(Arguments args, Account.Id id) {
protected static Predicate<ChangeData> cc(Arguments args, Account.Id id) {
// As noted above, CC is nebulous without NoteDb, but it certainly doesn't make sense to return
// Reviewers for cc:foo. Most likely this will just not match anything, but let the index sort
// it out.
return create(args, new ReviewerPredicate(ReviewerStateInternal.CC, id));
}
private static Predicate<ChangeData> anyReviewerState(Account.Id id) {
protected static Predicate<ChangeData> anyReviewerState(Account.Id id) {
return Predicate.or(
Stream.of(ReviewerStateInternal.values())
.filter(s -> s != ReviewerStateInternal.REMOVED)
@@ -60,8 +60,8 @@ class ReviewerPredicate extends ChangeIndexPredicate {
.collect(toList()));
}
private final ReviewerStateInternal state;
private final Account.Id id;
protected final ReviewerStateInternal state;
protected final Account.Id id;
private ReviewerPredicate(ReviewerStateInternal state, Account.Id id) {
super(ChangeField.REVIEWER, ChangeField.getReviewerFieldValue(state, id));
@@ -69,7 +69,7 @@ class ReviewerPredicate extends ChangeIndexPredicate {
this.id = id;
}
Account.Id getAccountId() {
protected Account.Id getAccountId() {
return id;
}

View File

@@ -19,17 +19,17 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gwtorm.server.OrmException;
class ReviewerinPredicate extends ChangeOperatorPredicate {
private final IdentifiedUser.GenericFactory userFactory;
private final AccountGroup.UUID uuid;
public class ReviewerinPredicate extends ChangeOperatorPredicate {
protected final IdentifiedUser.GenericFactory userFactory;
protected final AccountGroup.UUID uuid;
ReviewerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
public ReviewerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
super(ChangeQueryBuilder.FIELD_REVIEWERIN, uuid.toString());
this.userFactory = userFactory;
this.uuid = uuid;
}
AccountGroup.UUID getAccountGroupUUID() {
protected AccountGroup.UUID getAccountGroupUUID() {
return uuid;
}

View File

@@ -20,10 +20,10 @@ import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
public class StarPredicate extends ChangeIndexPredicate {
private final Account.Id accountId;
private final String label;
protected final Account.Id accountId;
protected final String label;
StarPredicate(Account.Id accountId, String label) {
public StarPredicate(Account.Id accountId, String label) {
super(ChangeField.STAR, StarredChangesUtil.StarField.create(accountId, label).toString());
this.accountId = accountId;
this.label = label;

View File

@@ -18,9 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class SubmissionIdPredicate extends ChangeIndexPredicate {
SubmissionIdPredicate(String changeSet) {
public class SubmissionIdPredicate extends ChangeIndexPredicate {
public SubmissionIdPredicate(String changeSet) {
super(ChangeField.SUBMISSIONID, changeSet);
}

View File

@@ -23,8 +23,8 @@ import com.google.gerrit.server.query.Predicate;
import com.google.gwtorm.server.OrmException;
import java.util.Set;
class SubmitRecordPredicate extends ChangeIndexPredicate {
static Predicate<ChangeData> create(
public class SubmitRecordPredicate extends ChangeIndexPredicate {
public static Predicate<ChangeData> create(
String label, SubmitRecord.Label.Status status, Set<Account.Id> accounts) {
String lowerLabel = label.toLowerCase();
if (accounts == null || accounts.isEmpty()) {

View File

@@ -18,10 +18,10 @@ import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gwtorm.server.OrmException;
class SubmittablePredicate extends ChangeIndexPredicate {
private final SubmitRecord.Status status;
public class SubmittablePredicate extends ChangeIndexPredicate {
protected final SubmitRecord.Status status;
SubmittablePredicate(SubmitRecord.Status status) {
public SubmittablePredicate(SubmitRecord.Status status) {
super(ChangeField.SUBMIT_RECORD, status.name());
this.status = status;
}

View File

@@ -24,12 +24,12 @@ import org.eclipse.jgit.revwalk.FooterLine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class TrackingIdPredicate extends ChangeIndexPredicate {
public class TrackingIdPredicate extends ChangeIndexPredicate {
private static final Logger log = LoggerFactory.getLogger(TrackingIdPredicate.class);
private final TrackingFooters trackingFooters;
protected final TrackingFooters trackingFooters;
TrackingIdPredicate(TrackingFooters trackingFooters, String trackingId) {
public TrackingIdPredicate(TrackingFooters trackingFooters, String trackingId) {
super(ChangeField.TR, trackingId);
this.trackingFooters = trackingFooters;
}

View File

@@ -23,10 +23,11 @@ import com.google.gerrit.server.query.account.AccountQueryBuilder;
import com.google.gwtorm.server.OrmException;
public class GroupIsVisibleToPredicate extends IsVisibleToPredicate<AccountGroup> {
private final GroupControl.GenericFactory groupControlFactory;
private final CurrentUser user;
protected final GroupControl.GenericFactory groupControlFactory;
protected final CurrentUser user;
GroupIsVisibleToPredicate(GroupControl.GenericFactory groupControlFactory, CurrentUser user) {
public GroupIsVisibleToPredicate(
GroupControl.GenericFactory groupControlFactory, CurrentUser user) {
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(user));
this.groupControlFactory = groupControlFactory;
this.user = user;