Skip to content

Apache Lucene open-source search software

Changed Term to implement Comparable.

Doug Cuttingc79abd35dd2f
diff --git a/src/java/org/apache/lucene/index/Term.java b/src/java/org/apache/lucene/index/Term.java
index 9c155efeb3e..d6d3f422048 100644
--- a/src/java/org/apache/lucene/index/Term.java
+++ b/src/java/org/apache/lucene/index/Term.java
@@ -62,7 +62,7 @@ package org.apache.lucene.index;
Note that terms may represent more than words from text fields, but also
things like dates, email addresses, urls, etc. */
-public final class Term implements java.io.Serializable {
+public final class Term implements Comparable, java.io.Serializable {
String field;
String text;
@@ -98,6 +98,10 @@ public final class Term implements java.io.Serializable {
return field.hashCode() + text.hashCode();
}
+ public int compareTo(Object other) {
+ return compareTo((Term)other);
+ }
+
/** Compares two terms, returning an integer which is less than zero iff this
term belongs after the argument, equal zero iff this term is equal to the
argument, and greater than zero iff this term belongs after the argument.