Lucene.Net.Util.StringHelper: Marked static, removed private ctor, made StartsWith(), EndsWith(), BytesDifference(), and SliceEquals() into extension methods
diff --git a/src/Lucene.Net/Util/StringHelper.cs b/src/Lucene.Net/Util/StringHelper.cs
index 0e32c3f..eb2e500 100644
--- a/src/Lucene.Net/Util/StringHelper.cs
+++ b/src/Lucene.Net/Util/StringHelper.cs
@@ -28,7 +28,7 @@
/// <para/>
/// @lucene.internal
/// </summary>
- public abstract class StringHelper
+ public static class StringHelper // LUCENENET specific - marked static and removed private constructor
{
/// <summary>
/// Pass this as the seed to <see cref="Murmurhash3_x86_32(byte[], int, int, int)"/>. </summary>
@@ -69,7 +69,7 @@
/// <param name="left"> The first <see cref="BytesRef"/> to compare. </param>
/// <param name="right"> The second <see cref="BytesRef"/> to compare. </param>
/// <returns> The number of common elements. </returns>
- public static int BytesDifference(BytesRef left, BytesRef right)
+ public static int BytesDifference(this BytesRef left, BytesRef right) // LUCENENET specific - converted to extension method
{
int len = left.Length < right.Length ? left.Length : right.Length;
var bytesLeft = left.Bytes;
@@ -86,10 +86,6 @@
return len;
}
- private StringHelper()
- {
- }
-
/// <summary> Returns a <see cref="T:IComparer{string}"/> over versioned strings such as X.YY.Z
/// <para/>
/// @lucene.internal
@@ -154,7 +150,7 @@
/// The expected prefix </param>
/// <returns> Returns <c>true</c> if the <paramref name="ref"/> starts with the given <paramref name="prefix"/>.
/// Otherwise <c>false</c>. </returns>
- public static bool StartsWith(BytesRef @ref, BytesRef prefix) // LUCENENET TODO: API - convert to extension method
+ public static bool StartsWith(this BytesRef @ref, BytesRef prefix) // LUCENENET specific - converted to extension method
{
return SliceEquals(@ref, prefix, 0);
}
@@ -169,12 +165,12 @@
/// The expected suffix </param>
/// <returns> Returns <c>true</c> if the <paramref name="ref"/> ends with the given <paramref name="suffix"/>.
/// Otherwise <c>false</c>. </returns>
- public static bool EndsWith(BytesRef @ref, BytesRef suffix) // LUCENENET TODO: API - convert to extension method
+ public static bool EndsWith(this BytesRef @ref, BytesRef suffix) // LUCENENET specific - converted to extension method
{
return SliceEquals(@ref, suffix, @ref.Length - suffix.Length);
}
- private static bool SliceEquals(BytesRef sliceToTest, BytesRef other, int pos)
+ private static bool SliceEquals(this BytesRef sliceToTest, BytesRef other, int pos) // LUCENENET specific - converted to extension method
{
if (pos < 0 || sliceToTest.Length - pos < other.Length)
{