You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/04/27 20:28:58 UTC
[Lucene.Net] svn commit: r1097201 - in
/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core:
Document/FieldSelectorResult.cs Index/SegmentInfo.cs Index/Term.cs
Author: digy
Date: Wed Apr 27 18:28:57 2011
New Revision: 1097201
URL: http://svn.apache.org/viewvc?rev=1097201&view=rev
Log:
[LUCENENET-412] IEquatable<T> for SegmentInfo, FieldSelectorResult & Term
Modified:
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentInfo.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs?rev=1097201&r1=1097200&r2=1097201&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs Wed Apr 27 18:28:57 2011
@@ -27,7 +27,7 @@ namespace Lucene.Net.Documents
/// </summary>
//Replace with an enumerated type in 1.5
[Serializable]
- public sealed class FieldSelectorResult
+ public sealed class FieldSelectorResult : IEquatable<FieldSelectorResult>
{
/// <summary> Load this {@link Field} every time the {@link Document} is loaded, reading in the data as it is encountered.
@@ -96,22 +96,25 @@ namespace Lucene.Net.Documents
public override bool Equals(System.Object o)
{
- if (this == o)
- return true;
- if (o == null || GetType() != o.GetType())
- return false;
-
- FieldSelectorResult that = (FieldSelectorResult) o;
-
- if (id != that.id)
- return false;
-
- return true;
+ return Equals(o as FieldSelectorResult);
}
+
+ public bool Equals(FieldSelectorResult other)
+ {
+ if (this == other)
+ return true;
+ if (other == null || GetType() != other.GetType())
+ return false;
+
+ if (id != other.id)
+ return false;
+
+ return true;
+ }
public override int GetHashCode()
{
return id;
}
- }
+ }
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentInfo.cs?rev=1097201&r1=1097200&r2=1097201&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentInfo.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentInfo.cs Wed Apr 27 18:28:57 2011
@@ -32,7 +32,7 @@ namespace Lucene.Net.Index
/// * <p/><b>NOTE:</b> This API is new and still experimental
/// (subject to change suddenly in the next release)<p/>
/// </summary>
- public sealed class SegmentInfo : System.ICloneable
+ public sealed class SegmentInfo : System.ICloneable,IEquatable<SegmentInfo>
{
internal const int NO = - 1; // e.g. no norms; no deletes;
@@ -875,10 +875,15 @@ namespace Lucene.Net.Index
}
return other.dir == dir && other.name.Equals(name);
}
+
+ public bool Equals(SegmentInfo other)
+ {
+ return other.dir == dir && other.name.Equals(name);
+ }
public override int GetHashCode()
{
return dir.GetHashCode() + name.GetHashCode();
}
- }
+ }
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs?rev=1097201&r1=1097200&r2=1097201&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs Wed Apr 27 18:28:57 2011
@@ -30,7 +30,7 @@ namespace Lucene.Net.Index
/// </summary>
[Serializable]
- public sealed class Term : System.IComparable, System.Runtime.Serialization.ISerializable
+ public sealed class Term : System.IComparable, System.Runtime.Serialization.ISerializable,IEquatable<Term>
{
internal System.String field;
internal System.String text;
@@ -94,29 +94,34 @@ namespace Lucene.Net.Index
//@Override
public override bool Equals(System.Object obj)
{
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (GetType() != obj.GetType())
- return false;
- Term other = (Term) obj;
- if (field == null)
- {
- if (other.field != null)
- return false;
- }
- else if (!field.Equals(other.field))
- return false;
- if (text == null)
- {
- if (other.text != null)
- return false;
- }
- else if (!text.Equals(other.text))
- return false;
- return true;
+ return Equals(obj as Term);
}
+
+ public bool Equals(Term other)
+ {
+ if (this == other)
+ return true;
+ if (other == null)
+ return false;
+ if (GetType() != other.GetType())
+ return false;
+
+ if (field == null)
+ {
+ if (other.field != null)
+ return false;
+ }
+ else if (!field.Equals(other.field))
+ return false;
+ if (text == null)
+ {
+ if (other.text != null)
+ return false;
+ }
+ else if (!text.Equals(other.text))
+ return false;
+ return true;
+ }
//@Override
public override int GetHashCode()
@@ -181,5 +186,5 @@ namespace Lucene.Net.Index
{
get { return text; }
}
- }
+ }
}
\ No newline at end of file