Index: src/java/org/apache/lucene/search/Sort.java =================================================================== --- src/java/org/apache/lucene/search/Sort.java (revision 724128) +++ src/java/org/apache/lucene/search/Sort.java (working copy) @@ -18,6 +18,7 @@ */ import java.io.Serializable; +import java.util.Arrays; /** @@ -222,4 +223,19 @@ return buffer.toString(); } + + /** Returns true if o is equal to this. */ + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Sort)) return false; + final Sort other = (Sort)o; + return Arrays.equals(this.fields, other.fields); + } + + /** Returns a hash code value for this object. */ + public int hashCode() { + // some Java 1.4 workaround, but the calculated hashCode + // is forward-compatible with Java 1.5's new Arrays.hashCode() + return 0x45aaf665 + Arrays.asList(fields).hashCode(); + } } Index: src/java/org/apache/lucene/search/SortField.java =================================================================== --- src/java/org/apache/lucene/search/SortField.java (revision 724128) +++ src/java/org/apache/lucene/search/SortField.java (working copy) @@ -244,4 +244,27 @@ return buffer.toString(); } + + /** Returns true if o is equal to this. */ + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof SortField)) return false; + final SortField other = (SortField)o; + return ( + other.field == this.field // field is always interned + && other.type == this.type + && other.reverse == this.reverse + && (other.locale == null ? this.locale == null : other.locale.equals(this.locale)) + && (other.factory == null ? this.factory == null : other.factory.equals(this.factory)) + ); + } + + /** Returns a hash code value for this object. */ + public int hashCode() { + int hash=type^0x346565dd + Boolean.valueOf(reverse).hashCode()^0xaf5998bb; + if (field != null) hash += field.hashCode()^0xff5685dd; + if (locale != null) hash += locale.hashCode()^0x08150815; + if (factory != null) hash += factory.hashCode()^0x34987555; + return hash; + } }