add missing hashcode/equals to these rewrite methods

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1451525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-03-01 08:43:15 +00:00
parent 6e14a97ccf
commit 527999b867
4 changed files with 62 additions and 0 deletions

View File

@ -163,4 +163,20 @@ public final class DocTermOrdsRewriteMethod extends MultiTermQuery.RewriteMethod
};
}
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return true;
}
@Override
public int hashCode() {
return 877;
}
}

View File

@ -162,4 +162,20 @@ public final class FieldCacheRewriteMethod extends MultiTermQuery.RewriteMethod
};
}
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return true;
}
@Override
public int hashCode() {
return 641;
}
}

View File

@ -126,4 +126,19 @@ public class TestDocTermOrdsRewriteMethod extends LuceneTestCase {
CheckHits.checkEqual(inverted, invertedDocs.scoreDocs, docValuesDocs.scoreDocs);
}
public void testEquals() throws Exception {
RegexpQuery a1 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
RegexpQuery a2 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
RegexpQuery b = new RegexpQuery(new Term(fieldName, "[bB]"), RegExp.NONE);
assertEquals(a1, a2);
assertFalse(a1.equals(b));
a1.setRewriteMethod(new DocTermOrdsRewriteMethod());
a2.setRewriteMethod(new DocTermOrdsRewriteMethod());
b.setRewriteMethod(new DocTermOrdsRewriteMethod());
assertEquals(a1, a2);
assertFalse(a1.equals(b));
QueryUtils.check(a1);
}
}

View File

@ -41,4 +41,19 @@ public class TestFieldCacheRewriteMethod extends TestRegexpRandom2 {
CheckHits.checkEqual(fieldCache, fieldCacheDocs.scoreDocs, filterDocs.scoreDocs);
}
public void testEquals() throws Exception {
RegexpQuery a1 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
RegexpQuery a2 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
RegexpQuery b = new RegexpQuery(new Term(fieldName, "[bB]"), RegExp.NONE);
assertEquals(a1, a2);
assertFalse(a1.equals(b));
a1.setRewriteMethod(new FieldCacheRewriteMethod());
a2.setRewriteMethod(new FieldCacheRewriteMethod());
b.setRewriteMethod(new FieldCacheRewriteMethod());
assertEquals(a1, a2);
assertFalse(a1.equals(b));
QueryUtils.check(a1);
}
}