Skip to content

Apache Lucene open-source search software

improve hashcodes: LUCENE-460

Yonik Seeley9513c471f6a1
diff --git a/src/java/org/apache/lucene/search/MultiPhraseQuery.java b/src/java/org/apache/lucene/search/MultiPhraseQuery.java
index ec7e75581f9..17ce727dff7 100644
--- a/src/java/org/apache/lucene/search/MultiPhraseQuery.java
+++ b/src/java/org/apache/lucene/search/MultiPhraseQuery.java
@@ -284,4 +284,24 @@ public class MultiPhraseQuery extends Query {
return buffer.toString();
}
+
+
+ /** Returns true if <code>o</code> is equal to this. */
+ public boolean equals(Object o) {
+ if (!(o instanceof MultiPhraseQuery)) return false;
+ MultiPhraseQuery other = (MultiPhraseQuery)o;
+ return this.getBoost() == other.getBoost()
+ && this.slop == other.slop
+ && this.termArrays.equals(other.termArrays)
+ && this.positions.equals(other.positions);
+ }
+
+ /** Returns a hash code value for this object.*/
+ public int hashCode() {
+ return Float.floatToIntBits(getBoost())
+ ^ slop
+ ^ termArrays.hashCode()
+ ^ positions.hashCode()
+ ^ 0x4AC65113;
+ }
}