This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit f347208359dd9f0a9141e5e3e2f0f2cfea384104
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jul 1 08:39:15 2020 -0400

    Sort members.
---
 .../text/matcher/AbstractStringMatcher.java        | 12 +++---
 .../apache/commons/text/matcher/StringMatcher.java | 50 +++++++++++-----------
 .../text/lookup/BiFunctionStringLookupTest.java    | 38 ++++++++--------
 3 files changed, 50 insertions(+), 50 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java 
b/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java
index e7cf3c4..357ad29 100644
--- a/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java
+++ b/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java
@@ -212,10 +212,10 @@ abstract class AbstractStringMatcher implements 
StringMatcher {
          *
          * @param str the string to match, must not be null
          */
-        StringMatcher(final String string) {
+        StringMatcher(final char... chars) {
             super();
-            this.string = string;
-            this.chars = string.toCharArray();
+            this.string = String.valueOf(chars);
+            this.chars = chars.clone();
         }
 
         /**
@@ -223,10 +223,10 @@ abstract class AbstractStringMatcher implements 
StringMatcher {
          *
          * @param str the string to match, must not be null
          */
-        StringMatcher(final char... chars) {
+        StringMatcher(final String string) {
             super();
-            this.string = String.valueOf(chars);
-            this.chars = chars.clone();
+            this.string = string;
+            this.chars = string.toCharArray();
         }
 
         /**
diff --git a/src/main/java/org/apache/commons/text/matcher/StringMatcher.java 
b/src/main/java/org/apache/commons/text/matcher/StringMatcher.java
index 8fa26f1..61b7055 100644
--- a/src/main/java/org/apache/commons/text/matcher/StringMatcher.java
+++ b/src/main/java/org/apache/commons/text/matcher/StringMatcher.java
@@ -50,31 +50,6 @@ public interface StringMatcher {
     }
 
     /**
-     * Returns the number of matching characters, zero for no match.
-     * <p>
-     * This method is called to check for a match. The parameter {@code pos} 
represents the current position to be
-     * checked in the string {@code buffer} (a character array which must not 
be changed). The API guarantees that
-     * {@code pos} is a valid index for {@code buffer}.
-     * </p>
-     * <p>
-     * The matching code may check one character or many. It may check 
characters preceding {@code pos} as well as those
-     * after.
-     * </p>
-     * <p>
-     * It must return zero for no match, or a positive number if a match was 
found. The number indicates the number of
-     * characters that matched.
-     * </p>
-     *
-     * @param buffer the text content to match against, do not change
-     * @param pos the starting position for the match, valid for buffer
-     * @return The number of matching characters, zero for no match
-     * @since 1.9
-     */
-    default int isMatch(final CharSequence buffer, final int pos) {
-        return isMatch(buffer, pos, 0, buffer.length());
-    }
-
-    /**
      * Returns the number of matching characters, {@code 0} if there is no 
match.
      * <p>
      * This method is called to check for a match against a source {@code 
buffer}. The parameter {@code start}
@@ -103,6 +78,31 @@ public interface StringMatcher {
     int isMatch(char[] buffer, int start, int bufferStart, int bufferEnd);
 
     /**
+     * Returns the number of matching characters, zero for no match.
+     * <p>
+     * This method is called to check for a match. The parameter {@code pos} 
represents the current position to be
+     * checked in the string {@code buffer} (a character array which must not 
be changed). The API guarantees that
+     * {@code pos} is a valid index for {@code buffer}.
+     * </p>
+     * <p>
+     * The matching code may check one character or many. It may check 
characters preceding {@code pos} as well as those
+     * after.
+     * </p>
+     * <p>
+     * It must return zero for no match, or a positive number if a match was 
found. The number indicates the number of
+     * characters that matched.
+     * </p>
+     *
+     * @param buffer the text content to match against, do not change
+     * @param pos the starting position for the match, valid for buffer
+     * @return The number of matching characters, zero for no match
+     * @since 1.9
+     */
+    default int isMatch(final CharSequence buffer, final int pos) {
+        return isMatch(buffer, pos, 0, buffer.length());
+    }
+
+    /**
      * Returns the number of matching characters, {@code 0} if there is no 
match.
      * <p>
      * This method is called to check for a match against a source {@code 
buffer}. The parameter {@code start}
diff --git 
a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java 
b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
index b85735d..c8e2588 100644
--- 
a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
+++ 
b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
@@ -31,25 +31,6 @@ import org.junit.jupiter.api.Test;
  */
 public class BiFunctionStringLookupTest {
 
-    @Test
-    public void testConcurrentHashMapNull() {
-        Assertions.assertNull(BiFunctionStringLookup.on(new 
ConcurrentHashMap<>()).lookup(null));
-    }
-
-    @Test
-    public void testHashMapNull() {
-        Assertions.assertNull(BiFunctionStringLookup.on(new 
HashMap<>()).lookup(null));
-    }
-
-    @Test
-    public void testOne() {
-        final String key = "key";
-        final String value = "value";
-        final Map<String, String> map = new HashMap<>();
-        map.put(key, value);
-        Assertions.assertEquals(value, 
FunctionStringLookup.on(map).lookup(key));
-    }
-
     private static final String SEPARATOR = ".";
 
     @SuppressWarnings("unchecked")
@@ -96,4 +77,23 @@ public class BiFunctionStringLookupTest {
             stringLookup.lookup(rootKey + SEPARATOR + subKeyMap + SEPARATOR + 
subSubKey, rootMap));
     }
 
+    @Test
+    public void testConcurrentHashMapNull() {
+        Assertions.assertNull(BiFunctionStringLookup.on(new 
ConcurrentHashMap<>()).lookup(null));
+    }
+
+    @Test
+    public void testHashMapNull() {
+        Assertions.assertNull(BiFunctionStringLookup.on(new 
HashMap<>()).lookup(null));
+    }
+
+    @Test
+    public void testOne() {
+        final String key = "key";
+        final String value = "value";
+        final Map<String, String> map = new HashMap<>();
+        map.put(key, value);
+        Assertions.assertEquals(value, 
FunctionStringLookup.on(map).lookup(key));
+    }
+
 }

Reply via email to