You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/01/26 14:38:07 UTC

[09/12] lucenenet git commit: Lucene.Net.Join.TermsQuery: Added missing Equals() and GetHashCode() implementations

Lucene.Net.Join.TermsQuery: Added missing Equals() and GetHashCode() implementations


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/96a10db6
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/96a10db6
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/96a10db6

Branch: refs/heads/api-work
Commit: 96a10db6379617ac3230d663ae45380784b63990
Parents: e41541f
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jan 26 20:11:53 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jan 26 20:11:53 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Join/TermsQuery.cs | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96a10db6/src/Lucene.Net.Join/TermsQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Join/TermsQuery.cs b/src/Lucene.Net.Join/TermsQuery.cs
index a869c9a..5b471ce 100644
--- a/src/Lucene.Net.Join/TermsQuery.cs
+++ b/src/Lucene.Net.Join/TermsQuery.cs
@@ -64,7 +64,36 @@ namespace Lucene.Net.Join
             return string.Format("TermsQuery{{field={0}}}", field);
         }
 
-        // LUCENENET TODO: Add GetHashCode() from Lucene
+        public override bool Equals(object obj)
+        {
+            if (this == obj)
+            {
+                return true;
+            }
+            if (!base.Equals(obj))
+            {
+                return false;
+            }
+            if (GetType() != obj.GetType())
+            {
+                return false;
+            }
+
+            TermsQuery other = (TermsQuery)obj;
+            if (!_fromQuery.Equals(other._fromQuery))
+            {
+                return false;
+            }
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            int prime = 31;
+            int result = base.GetHashCode();
+            result += prime * _fromQuery.GetHashCode();
+            return result;
+        }
 
         private class SeekingTermSetTermsEnum : FilteredTermsEnum
         {