Skip to content

Apache Lucene open-source search software

Generify more Comparable interface declarations

Uwe Schindlera0776e5cd0ae
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java
index ca5ec0512b7..809dc209f95 100755
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java
@@ -32,7 +32,7 @@ import java.util.Map;
* or each pair as its own field, etc., - and this of course must match the way the
* searched index was constructed.
*/
-public class QualityQuery implements Comparable {
+public class QualityQuery implements Comparable<QualityQuery> {
private String queryID;
private Map nameValPairs;
@@ -71,8 +71,7 @@ public class QualityQuery implements Comparable {
/* for a nicer sort of input queries before running them.
* Try first as ints, fall back to string if not int. */
- public int compareTo(Object o) {
- QualityQuery other = (QualityQuery) o;
+ public int compareTo(QualityQuery other) {
try {
// compare as ints when ids ints
int n = Integer.parseInt(queryID);
diff --git a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java
index 9f55e477906..be7edc68c36 100644
--- a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java
+++ b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java
@@ -27,7 +27,7 @@ import org.apache.lucene.search.Query;
public abstract class SimpleTerm
extends SrndQuery
- implements DistanceSubQuery, Comparable
+ implements DistanceSubQuery, Comparable<SimpleTerm>
{
public SimpleTerm(boolean q) {quoted = q;}
@@ -39,9 +39,8 @@ public abstract class SimpleTerm
public abstract String toStringUnquoted();
- public int compareTo(Object o) {
+ public int compareTo(SimpleTerm ost) {
/* for ordering terms and prefixes before using an index, not used */
- SimpleTerm ost = (SimpleTerm) o;
return this.toStringUnquoted().compareTo( ost.toStringUnquoted());
}
diff --git a/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java b/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
index 3863fdc7b05..5e4038bc8ee 100644
--- a/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
+++ b/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
@@ -24,7 +24,7 @@ import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
// TODO: break into separate freq and prox writers as
// codecs; make separate container (tii/tis/skip/*) that can
// be configured as any number of files 1..N
-final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implements Comparable {
+final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implements Comparable<FreqProxTermsWriterPerField> {
final FreqProxTermsWriterPerThread perThread;
final TermsHashPerField termsHashPerField;
@@ -56,8 +56,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
void skippingLongTerm() throws IOException {}
- public int compareTo(Object other0) {
- FreqProxTermsWriterPerField other = (FreqProxTermsWriterPerField) other0;
+ public int compareTo(FreqProxTermsWriterPerField other) {
return fieldInfo.name.compareTo(other.fieldInfo.name);
}
diff --git a/src/java/org/apache/lucene/index/IndexFileDeleter.java b/src/java/org/apache/lucene/index/IndexFileDeleter.java
index d974372925d..6313586b6c4 100644
--- a/src/java/org/apache/lucene/index/IndexFileDeleter.java
+++ b/src/java/org/apache/lucene/index/IndexFileDeleter.java
@@ -567,7 +567,7 @@ final class IndexFileDeleter {
* equals.
*/
- final private static class CommitPoint extends IndexCommit implements Comparable {
+ final private static class CommitPoint extends IndexCommit implements Comparable<CommitPoint> {
long gen;
Collection files;
@@ -637,8 +637,7 @@ final class IndexFileDeleter {
return deleted;
}
- public int compareTo(Object obj) {
- CommitPoint commit = (CommitPoint) obj;
+ public int compareTo(CommitPoint commit) {
if (gen < commit.gen) {
return -1;
} else if (gen > commit.gen) {
diff --git a/src/java/org/apache/lucene/index/NormsWriterPerField.java b/src/java/org/apache/lucene/index/NormsWriterPerField.java
index 34364de5af7..52c08f03b6e 100644
--- a/src/java/org/apache/lucene/index/NormsWriterPerField.java
+++ b/src/java/org/apache/lucene/index/NormsWriterPerField.java
@@ -25,7 +25,7 @@ import org.apache.lucene.search.Similarity;
* just look at the length for the field (docState.length)
* and record the norm. */
-final class NormsWriterPerField extends InvertedDocEndConsumerPerField implements Comparable {
+final class NormsWriterPerField extends InvertedDocEndConsumerPerField implements Comparable<NormsWriterPerField> {
final NormsWriterPerThread perThread;
final FieldInfo fieldInfo;
@@ -56,8 +56,8 @@ final class NormsWriterPerField extends InvertedDocEndConsumerPerField implement
upto = 0;
}
- public int compareTo(Object other) {
- return fieldInfo.name.compareTo(((NormsWriterPerField) other).fieldInfo.name);
+ public int compareTo(NormsWriterPerField other) {
+ return fieldInfo.name.compareTo(other.fieldInfo.name);
}
void finish() {
diff --git a/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/src/test/org/apache/lucene/index/TestTermVectorsReader.java
index f7e55ac1f58..2c9dd3f3da2 100644
--- a/src/test/org/apache/lucene/index/TestTermVectorsReader.java
+++ b/src/test/org/apache/lucene/index/TestTermVectorsReader.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.SortedSet;
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
@@ -51,13 +52,13 @@ public class TestTermVectorsReader extends LuceneTestCase {
super(s);
}
- private class TestToken implements Comparable {
+ private class TestToken implements Comparable<TestToken> {
String text;
int pos;
int startOffset;
int endOffset;
- public int compareTo(Object other) {
- return pos - ((TestToken) other).pos;
+ public int compareTo(TestToken other) {
+ return pos - other.pos;
}
}