Remove superfluous final from server/query/
Change-Id: I65222959ecf27a3b1441d1badd8a68a1b735ebe1
This commit is contained in:
@@ -29,11 +29,11 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
private final int cost;
|
||||
|
||||
@SafeVarargs
|
||||
protected AndPredicate(final Predicate<T>... that) {
|
||||
protected AndPredicate(Predicate<T>... that) {
|
||||
this(Arrays.asList(that));
|
||||
}
|
||||
|
||||
protected AndPredicate(final Collection<? extends Predicate<T>> that) {
|
||||
protected AndPredicate(Collection<? extends Predicate<T>> that) {
|
||||
List<Predicate<T>> t = new ArrayList<>(that.size());
|
||||
int c = 0;
|
||||
for (Predicate<T> p : that) {
|
||||
@@ -62,12 +62,12 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Predicate<T> getChild(final int i) {
|
||||
public final Predicate<T> getChild(int i) {
|
||||
return children.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) {
|
||||
public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
|
||||
return new AndPredicate<>(children);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(final T object) throws OrmException {
|
||||
public boolean match(T object) throws OrmException {
|
||||
for (Predicate<T> c : children) {
|
||||
checkState(
|
||||
c.isMatchable(),
|
||||
@@ -107,7 +107,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -18,12 +18,12 @@ package com.google.gerrit.server.query;
|
||||
public abstract class IntPredicate<T> extends OperatorPredicate<T> {
|
||||
private final int intValue;
|
||||
|
||||
public IntPredicate(final String name, final String value) {
|
||||
public IntPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
this.intValue = Integer.parseInt(value);
|
||||
}
|
||||
|
||||
public IntPredicate(final String name, final int intValue) {
|
||||
public IntPredicate(String name, int intValue) {
|
||||
super(name, String.valueOf(intValue));
|
||||
this.intValue = intValue;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public abstract class IntPredicate<T> extends OperatorPredicate<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
private final Predicate<T> that;
|
||||
|
||||
protected NotPredicate(final Predicate<T> that) {
|
||||
protected NotPredicate(Predicate<T> that) {
|
||||
if (that instanceof NotPredicate) {
|
||||
throw new IllegalArgumentException("Double negation unsupported");
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Predicate<T> getChild(final int i) {
|
||||
public final Predicate<T> getChild(int i) {
|
||||
if (i != 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(i);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) {
|
||||
public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
|
||||
if (children.size() != 1) {
|
||||
throw new IllegalArgumentException("Expected exactly one child");
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(final T object) throws OrmException {
|
||||
public boolean match(T object) throws OrmException {
|
||||
checkState(
|
||||
that.isMatchable(),
|
||||
"match invoked, but child predicate %s doesn't implement %s",
|
||||
@@ -84,7 +84,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
|
||||
protected final String name;
|
||||
protected final String value;
|
||||
|
||||
public OperatorPredicate(final String name, final String value) {
|
||||
public OperatorPredicate(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) {
|
||||
public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
|
||||
if (!children.isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected 0 children");
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -29,11 +29,11 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
private final int cost;
|
||||
|
||||
@SafeVarargs
|
||||
protected OrPredicate(final Predicate<T>... that) {
|
||||
protected OrPredicate(Predicate<T>... that) {
|
||||
this(Arrays.asList(that));
|
||||
}
|
||||
|
||||
protected OrPredicate(final Collection<? extends Predicate<T>> that) {
|
||||
protected OrPredicate(Collection<? extends Predicate<T>> that) {
|
||||
List<Predicate<T>> t = new ArrayList<>(that.size());
|
||||
int c = 0;
|
||||
for (Predicate<T> p : that) {
|
||||
@@ -62,12 +62,12 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Predicate<T> getChild(final int i) {
|
||||
public final Predicate<T> getChild(int i) {
|
||||
return children.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) {
|
||||
public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
|
||||
return new OrPredicate<>(children);
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(final T object) throws OrmException {
|
||||
for (final Predicate<T> c : children) {
|
||||
public boolean match(T object) throws OrmException {
|
||||
for (Predicate<T> c : children) {
|
||||
checkState(
|
||||
c.isMatchable(),
|
||||
"match invoked, but child predicate %s doesn't implement %s",
|
||||
@@ -107,7 +107,7 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public abstract class Predicate<T> {
|
||||
|
||||
/** Combine the passed predicates into a single AND node. */
|
||||
@SafeVarargs
|
||||
public static <T> Predicate<T> and(final Predicate<T>... that) {
|
||||
public static <T> Predicate<T> and(Predicate<T>... that) {
|
||||
if (that.length == 1) {
|
||||
return that[0];
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public abstract class Predicate<T> {
|
||||
}
|
||||
|
||||
/** Combine the passed predicates into a single AND node. */
|
||||
public static <T> Predicate<T> and(final Collection<? extends Predicate<T>> that) {
|
||||
public static <T> Predicate<T> and(Collection<? extends Predicate<T>> that) {
|
||||
if (that.size() == 1) {
|
||||
return Iterables.getOnlyElement(that);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public abstract class Predicate<T> {
|
||||
|
||||
/** Combine the passed predicates into a single OR node. */
|
||||
@SafeVarargs
|
||||
public static <T> Predicate<T> or(final Predicate<T>... that) {
|
||||
public static <T> Predicate<T> or(Predicate<T>... that) {
|
||||
if (that.length == 1) {
|
||||
return that[0];
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public abstract class Predicate<T> {
|
||||
}
|
||||
|
||||
/** Combine the passed predicates into a single OR node. */
|
||||
public static <T> Predicate<T> or(final Collection<? extends Predicate<T>> that) {
|
||||
public static <T> Predicate<T> or(Collection<? extends Predicate<T>> that) {
|
||||
if (that.size() == 1) {
|
||||
return Iterables.getOnlyElement(that);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public abstract class Predicate<T> {
|
||||
}
|
||||
|
||||
/** Invert the passed node. */
|
||||
public static <T> Predicate<T> not(final Predicate<T> that) {
|
||||
public static <T> Predicate<T> not(Predicate<T> that) {
|
||||
if (that instanceof NotPredicate) {
|
||||
// Negate of a negate is the original predicate.
|
||||
//
|
||||
@@ -101,7 +101,7 @@ public abstract class Predicate<T> {
|
||||
}
|
||||
|
||||
/** Same as {@code getChildren().get(i)} */
|
||||
public Predicate<T> getChild(final int i) {
|
||||
public Predicate<T> getChild(int i) {
|
||||
return getChildren().get(i);
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ import org.antlr.runtime.tree.Tree;
|
||||
*
|
||||
* <pre>
|
||||
* @Operator
|
||||
* public Predicate is(final String value) {
|
||||
* public Predicate is(String value) {
|
||||
* if ("starred".equals(value)) {
|
||||
* return new StarredPredicate();
|
||||
* }
|
||||
@@ -180,7 +180,7 @@ public abstract class QueryBuilder<T> {
|
||||
* This may be due to a syntax error, may be due to an operator not being supported, or due to
|
||||
* an invalid value being passed to a recognized operator.
|
||||
*/
|
||||
public Predicate<T> parse(final String query) throws QueryParseException {
|
||||
public Predicate<T> parse(String query) throws QueryParseException {
|
||||
if (Strings.isNullOrEmpty(query)) {
|
||||
throw new QueryParseException("query is empty");
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public abstract class QueryBuilder<T> {
|
||||
* parser. This may be due to a syntax error, may be due to an operator not being supported,
|
||||
* or due to an invalid value being passed to a recognized operator.
|
||||
*/
|
||||
public List<Predicate<T>> parse(final List<String> queries) throws QueryParseException {
|
||||
public List<Predicate<T>> parse(List<String> queries) throws QueryParseException {
|
||||
List<Predicate<T>> predicates = new ArrayList<>(queries.size());
|
||||
for (String query : queries) {
|
||||
predicates.add(parse(query));
|
||||
@@ -204,7 +204,7 @@ public abstract class QueryBuilder<T> {
|
||||
return predicates;
|
||||
}
|
||||
|
||||
private Predicate<T> toPredicate(final Tree r)
|
||||
private Predicate<T> toPredicate(Tree r)
|
||||
throws QueryParseException, IllegalArgumentException {
|
||||
switch (r.getType()) {
|
||||
case AND:
|
||||
@@ -225,7 +225,7 @@ public abstract class QueryBuilder<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate<T> operator(final String name, final Tree val) throws QueryParseException {
|
||||
private Predicate<T> operator(String name, Tree val) throws QueryParseException {
|
||||
switch (val.getType()) {
|
||||
// Expand multiple values, "foo:(a b c)", as though they were written
|
||||
// out with the longer form, "foo:a foo:b foo:c".
|
||||
@@ -257,7 +257,7 @@ public abstract class QueryBuilder<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Predicate<T> operator(final String name, final String value) throws QueryParseException {
|
||||
private Predicate<T> operator(String name, String value) throws QueryParseException {
|
||||
@SuppressWarnings("rawtypes")
|
||||
OperatorFactory f = opFactories.get(name);
|
||||
if (f == null) {
|
||||
@@ -266,7 +266,7 @@ public abstract class QueryBuilder<T> {
|
||||
return f.create(this, value);
|
||||
}
|
||||
|
||||
private Predicate<T> defaultField(final Tree r) throws QueryParseException {
|
||||
private Predicate<T> defaultField(Tree r) throws QueryParseException {
|
||||
switch (r.getType()) {
|
||||
case SINGLE_WORD:
|
||||
case EXACT_PHRASE:
|
||||
@@ -291,11 +291,11 @@ public abstract class QueryBuilder<T> {
|
||||
* @return predicate representing this value.
|
||||
* @throws QueryParseException the parser does not recognize this value.
|
||||
*/
|
||||
protected Predicate<T> defaultField(final String value) throws QueryParseException {
|
||||
protected Predicate<T> defaultField(String value) throws QueryParseException {
|
||||
throw error("Unsupported query:" + value);
|
||||
}
|
||||
|
||||
private List<Predicate<T>> children(final Tree r)
|
||||
private List<Predicate<T>> children(Tree r)
|
||||
throws QueryParseException, IllegalArgumentException {
|
||||
List<Predicate<T>> p = new ArrayList<>(r.getChildCount());
|
||||
for (int i = 0; i < r.getChildCount(); i++) {
|
||||
@@ -304,7 +304,7 @@ public abstract class QueryBuilder<T> {
|
||||
return p;
|
||||
}
|
||||
|
||||
private Tree onlyChildOf(final Tree r) throws QueryParseException {
|
||||
private Tree onlyChildOf(Tree r) throws QueryParseException {
|
||||
if (r.getChildCount() != 1) {
|
||||
throw error("Expected exactly one child: " + r);
|
||||
}
|
||||
@@ -329,7 +329,7 @@ public abstract class QueryBuilder<T> {
|
||||
private final String name;
|
||||
private final Method method;
|
||||
|
||||
ReflectionFactory(final String name, final Method method) {
|
||||
ReflectionFactory(String name, Method method) {
|
||||
this.name = name;
|
||||
this.method = method;
|
||||
}
|
||||
|
Reference in New Issue
Block a user