Remove superfluous final from server/query/

Change-Id: I65222959ecf27a3b1441d1badd8a68a1b735ebe1
This commit is contained in:
Han-Wen Nienhuys
2017-06-13 16:55:41 +02:00
parent 4d7645378e
commit 307eb1ed96
7 changed files with 41 additions and 41 deletions

View File

@@ -29,11 +29,11 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
private final int cost; private final int cost;
@SafeVarargs @SafeVarargs
protected AndPredicate(final Predicate<T>... that) { protected AndPredicate(Predicate<T>... that) {
this(Arrays.asList(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()); List<Predicate<T>> t = new ArrayList<>(that.size());
int c = 0; int c = 0;
for (Predicate<T> p : that) { for (Predicate<T> p : that) {
@@ -62,12 +62,12 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public final Predicate<T> getChild(final int i) { public final Predicate<T> getChild(int i) {
return children.get(i); return children.get(i);
} }
@Override @Override
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) { public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
return new AndPredicate<>(children); return new AndPredicate<>(children);
} }
@@ -82,7 +82,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(final T object) throws OrmException { public boolean match(T object) throws OrmException {
for (Predicate<T> c : children) { for (Predicate<T> c : children) {
checkState( checkState(
c.isMatchable(), c.isMatchable(),
@@ -107,7 +107,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean equals(final Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }

View File

@@ -18,12 +18,12 @@ package com.google.gerrit.server.query;
public abstract class IntPredicate<T> extends OperatorPredicate<T> { public abstract class IntPredicate<T> extends OperatorPredicate<T> {
private final int intValue; private final int intValue;
public IntPredicate(final String name, final String value) { public IntPredicate(String name, String value) {
super(name, value); super(name, value);
this.intValue = Integer.parseInt(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)); super(name, String.valueOf(intValue));
this.intValue = intValue; this.intValue = intValue;
} }
@@ -38,7 +38,7 @@ public abstract class IntPredicate<T> extends OperatorPredicate<T> {
} }
@Override @Override
public boolean equals(final Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }

View File

@@ -25,7 +25,7 @@ import java.util.List;
public class NotPredicate<T> extends Predicate<T> implements Matchable<T> { public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
private final Predicate<T> that; private final Predicate<T> that;
protected NotPredicate(final Predicate<T> that) { protected NotPredicate(Predicate<T> that) {
if (that instanceof NotPredicate) { if (that instanceof NotPredicate) {
throw new IllegalArgumentException("Double negation unsupported"); throw new IllegalArgumentException("Double negation unsupported");
} }
@@ -43,7 +43,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public final Predicate<T> getChild(final int i) { public final Predicate<T> getChild(int i) {
if (i != 0) { if (i != 0) {
throw new ArrayIndexOutOfBoundsException(i); throw new ArrayIndexOutOfBoundsException(i);
} }
@@ -51,7 +51,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) { public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
if (children.size() != 1) { if (children.size() != 1) {
throw new IllegalArgumentException("Expected exactly one child"); throw new IllegalArgumentException("Expected exactly one child");
} }
@@ -64,7 +64,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(final T object) throws OrmException { public boolean match(T object) throws OrmException {
checkState( checkState(
that.isMatchable(), that.isMatchable(),
"match invoked, but child predicate %s doesn't implement %s", "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 @Override
public boolean equals(final Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }

View File

@@ -21,7 +21,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
protected final String name; protected final String name;
protected final String value; protected final String value;
public OperatorPredicate(final String name, final String value) { public OperatorPredicate(String name, String value) {
this.name = name; this.name = name;
this.value = value; this.value = value;
} }
@@ -35,7 +35,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
} }
@Override @Override
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) { public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
if (!children.isEmpty()) { if (!children.isEmpty()) {
throw new IllegalArgumentException("Expected 0 children"); throw new IllegalArgumentException("Expected 0 children");
} }
@@ -48,7 +48,7 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
} }
@Override @Override
public boolean equals(final Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }

View File

@@ -29,11 +29,11 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
private final int cost; private final int cost;
@SafeVarargs @SafeVarargs
protected OrPredicate(final Predicate<T>... that) { protected OrPredicate(Predicate<T>... that) {
this(Arrays.asList(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()); List<Predicate<T>> t = new ArrayList<>(that.size());
int c = 0; int c = 0;
for (Predicate<T> p : that) { for (Predicate<T> p : that) {
@@ -62,12 +62,12 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public final Predicate<T> getChild(final int i) { public final Predicate<T> getChild(int i) {
return children.get(i); return children.get(i);
} }
@Override @Override
public Predicate<T> copy(final Collection<? extends Predicate<T>> children) { public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
return new OrPredicate<>(children); return new OrPredicate<>(children);
} }
@@ -82,8 +82,8 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(final T object) throws OrmException { public boolean match(T object) throws OrmException {
for (final Predicate<T> c : children) { for (Predicate<T> c : children) {
checkState( checkState(
c.isMatchable(), c.isMatchable(),
"match invoked, but child predicate %s doesn't implement %s", "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 @Override
public boolean equals(final Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }

View File

@@ -48,7 +48,7 @@ public abstract class Predicate<T> {
/** Combine the passed predicates into a single AND node. */ /** Combine the passed predicates into a single AND node. */
@SafeVarargs @SafeVarargs
public static <T> Predicate<T> and(final Predicate<T>... that) { public static <T> Predicate<T> and(Predicate<T>... that) {
if (that.length == 1) { if (that.length == 1) {
return that[0]; return that[0];
} }
@@ -56,7 +56,7 @@ public abstract class Predicate<T> {
} }
/** Combine the passed predicates into a single AND node. */ /** 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) { if (that.size() == 1) {
return Iterables.getOnlyElement(that); return Iterables.getOnlyElement(that);
} }
@@ -65,7 +65,7 @@ public abstract class Predicate<T> {
/** Combine the passed predicates into a single OR node. */ /** Combine the passed predicates into a single OR node. */
@SafeVarargs @SafeVarargs
public static <T> Predicate<T> or(final Predicate<T>... that) { public static <T> Predicate<T> or(Predicate<T>... that) {
if (that.length == 1) { if (that.length == 1) {
return that[0]; return that[0];
} }
@@ -73,7 +73,7 @@ public abstract class Predicate<T> {
} }
/** Combine the passed predicates into a single OR node. */ /** 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) { if (that.size() == 1) {
return Iterables.getOnlyElement(that); return Iterables.getOnlyElement(that);
} }
@@ -81,7 +81,7 @@ public abstract class Predicate<T> {
} }
/** Invert the passed node. */ /** 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) { if (that instanceof NotPredicate) {
// Negate of a negate is the original predicate. // Negate of a negate is the original predicate.
// //
@@ -101,7 +101,7 @@ public abstract class Predicate<T> {
} }
/** Same as {@code getChildren().get(i)} */ /** Same as {@code getChildren().get(i)} */
public Predicate<T> getChild(final int i) { public Predicate<T> getChild(int i) {
return getChildren().get(i); return getChildren().get(i);
} }

View File

@@ -48,7 +48,7 @@ import org.antlr.runtime.tree.Tree;
* *
* <pre> * <pre>
* &#064;Operator * &#064;Operator
* public Predicate is(final String value) { * public Predicate is(String value) {
* if (&quot;starred&quot;.equals(value)) { * if (&quot;starred&quot;.equals(value)) {
* return new StarredPredicate(); * 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 * 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. * 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)) { if (Strings.isNullOrEmpty(query)) {
throw new QueryParseException("query is empty"); 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, * 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. * 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()); List<Predicate<T>> predicates = new ArrayList<>(queries.size());
for (String query : queries) { for (String query : queries) {
predicates.add(parse(query)); predicates.add(parse(query));
@@ -204,7 +204,7 @@ public abstract class QueryBuilder<T> {
return predicates; return predicates;
} }
private Predicate<T> toPredicate(final Tree r) private Predicate<T> toPredicate(Tree r)
throws QueryParseException, IllegalArgumentException { throws QueryParseException, IllegalArgumentException {
switch (r.getType()) { switch (r.getType()) {
case AND: 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()) { switch (val.getType()) {
// Expand multiple values, "foo:(a b c)", as though they were written // Expand multiple values, "foo:(a b c)", as though they were written
// out with the longer form, "foo:a foo:b foo:c". // out with the longer form, "foo:a foo:b foo:c".
@@ -257,7 +257,7 @@ public abstract class QueryBuilder<T> {
} }
@SuppressWarnings("unchecked") @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") @SuppressWarnings("rawtypes")
OperatorFactory f = opFactories.get(name); OperatorFactory f = opFactories.get(name);
if (f == null) { if (f == null) {
@@ -266,7 +266,7 @@ public abstract class QueryBuilder<T> {
return f.create(this, value); 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()) { switch (r.getType()) {
case SINGLE_WORD: case SINGLE_WORD:
case EXACT_PHRASE: case EXACT_PHRASE:
@@ -291,11 +291,11 @@ public abstract class QueryBuilder<T> {
* @return predicate representing this value. * @return predicate representing this value.
* @throws QueryParseException the parser does not recognize 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); throw error("Unsupported query:" + value);
} }
private List<Predicate<T>> children(final Tree r) private List<Predicate<T>> children(Tree r)
throws QueryParseException, IllegalArgumentException { throws QueryParseException, IllegalArgumentException {
List<Predicate<T>> p = new ArrayList<>(r.getChildCount()); List<Predicate<T>> p = new ArrayList<>(r.getChildCount());
for (int i = 0; i < r.getChildCount(); i++) { for (int i = 0; i < r.getChildCount(); i++) {
@@ -304,7 +304,7 @@ public abstract class QueryBuilder<T> {
return p; return p;
} }
private Tree onlyChildOf(final Tree r) throws QueryParseException { private Tree onlyChildOf(Tree r) throws QueryParseException {
if (r.getChildCount() != 1) { if (r.getChildCount() != 1) {
throw error("Expected exactly one child: " + r); throw error("Expected exactly one child: " + r);
} }
@@ -329,7 +329,7 @@ public abstract class QueryBuilder<T> {
private final String name; private final String name;
private final Method method; private final Method method;
ReflectionFactory(final String name, final Method method) { ReflectionFactory(String name, Method method) {
this.name = name; this.name = name;
this.method = method; this.method = method;
} }