Repository: commons-text
Updated Branches:
  refs/heads/master 388fa72c1 -> 1de362f43


[TEXT-113] Add an interpolator string lookup. No long needs to subclass
StrLookup. Fix Checkstyle errors. Add Javadoc comments. Clean ups.

Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1de362f4
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1de362f4
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1de362f4

Branch: refs/heads/master
Commit: 1de362f43968de500c4ef5a80672b4efbb27ae49
Parents: 388fa72
Author: Gary Gregory <garydgreg...@gmail.com>
Authored: Sun Feb 11 11:15:35 2018 -0700
Committer: Gary Gregory <garydgreg...@gmail.com>
Committed: Sun Feb 11 11:15:35 2018 -0700

----------------------------------------------------------------------
 .../commons/text/lookup/AbstractStringLookup.java  |  2 +-
 .../text/lookup/InterpolatorStringLookup.java      |  1 -
 .../commons/text/lookup/MapStringLookup.java       |  4 ++--
 .../apache/commons/text/StrSubstitutorTest.java    | 17 ++++++++---------
 4 files changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java
index 563d165..bb43e96 100644
--- a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java
@@ -26,6 +26,6 @@ package org.apache.commons.text.lookup;
  *
  * @since 1.3
  */
-public abstract class AbstractStringLookup implements StringLookup {
+abstract class AbstractStringLookup implements StringLookup {
     // nothing yet
 }

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
index ccf823b..1eddf43 100644
--- a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
@@ -69,7 +69,6 @@ class InterpolatorStringLookup extends AbstractStringLookup {
      */
     <V> InterpolatorStringLookup(final Map<String, V> defaultMap) {
         this(MapStringLookup.on(defaultMap == null ? new HashMap<String, V>() 
: defaultMap));
-        // TODO: Use a service loader
         stringLookupMap.put("sys", SystemPropertyStringLookup.INSTANCE);
         stringLookupMap.put("env", EnvironmentVariableStringLookup.INSTANCE);
         stringLookupMap.put("java", JavaPlatformStringLookup.INSTANCE);

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java
index b85bcf5..dedd77a 100644
--- a/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java
@@ -26,7 +26,7 @@ import java.util.Map;
  *
  * @since 1.3
  */
-public final class MapStringLookup<V> implements StringLookup {
+final class MapStringLookup<V> implements StringLookup {
 
     /**
      * Creates a new instance backed by a Map. Used by the default lookup.
@@ -37,7 +37,7 @@ public final class MapStringLookup<V> implements StringLookup 
{
      *            the map of keys to values, may be null.
      * @return a new instance backed by the given map.
      */
-    public static <T> MapStringLookup<T> on(final Map<String, T> map) {
+    static <T> MapStringLookup<T> on(final Map<String, T> map) {
         return new MapStringLookup<>(map);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/test/java/org/apache/commons/text/StrSubstitutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrSubstitutorTest.java 
b/src/test/java/org/apache/commons/text/StrSubstitutorTest.java
index 8cd435a..4ab52ed 100644
--- a/src/test/java/org/apache/commons/text/StrSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StrSubstitutorTest.java
@@ -29,7 +29,6 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.commons.lang3.mutable.MutableObject;
-import org.apache.commons.text.lookup.MapStringLookup;
 import org.apache.commons.text.lookup.StringLookup;
 import org.apache.commons.text.lookup.StringLookupFactory;
 import org.junit.After;
@@ -770,10 +769,10 @@ public class StrSubstitutorTest {
     @Test
     public void testReplaceInTakingTwoAndThreeIntsReturningFalse() {
         final Map<String, Object> hashMap = new HashMap<>();
-        final MapStringLookup<Object> strLookupMapStrLookup = 
MapStringLookup.on(hashMap);
+        final StringLookup mapStringLookup = 
StringLookupFactory.INSTANCE.mapStringLookup(hashMap);
         final StrMatcher strMatcher = StrMatcher.tabMatcher();
         final StrSubstitutor strSubstitutor =
-                new StrSubstitutor(strLookupMapStrLookup, strMatcher, 
strMatcher, 'b', strMatcher);
+                new StrSubstitutor(mapStringLookup, strMatcher, strMatcher, 
'b', strMatcher);
 
         assertFalse(strSubstitutor.replaceIn((StringBuilder) null, 1315, 
(-1369)));
         assertEquals('b', strSubstitutor.getEscapeChar());
@@ -783,10 +782,10 @@ public class StrSubstitutorTest {
     @Test
     public void testReplaceInTakingTwoAndThreeIntsReturningFalse_deprecated() {
         final Map<String, Object> hashMap = new HashMap<>();
-        final StrLookup.MapStrLookup<Object> strLookupMapStrLookup = new 
StrLookup.MapStrLookup<>(hashMap);
+        final StrLookup.MapStrLookup<Object> mapStrLookup = new 
StrLookup.MapStrLookup<>(hashMap);
         final StrMatcher strMatcher = StrMatcher.tabMatcher();
         final StrSubstitutor strSubstitutor =
-                new StrSubstitutor(strLookupMapStrLookup, strMatcher, 
strMatcher, 'b', strMatcher);
+                new StrSubstitutor(mapStrLookup, strMatcher, strMatcher, 'b', 
strMatcher);
 
         assertFalse(strSubstitutor.replaceIn((StringBuilder) null, 1315, 
(-1369)));
         assertEquals('b', strSubstitutor.getEscapeChar());
@@ -826,8 +825,8 @@ public class StrSubstitutorTest {
     @Test
     public void 
testCreatesStrSubstitutorTakingStrLookupAndCallsReplaceTakingTwoAndThreeInts() {
         final Map<String, CharacterPredicates> map = new HashMap<>();
-        final MapStringLookup<CharacterPredicates> strLookupMapStrLookup = 
MapStringLookup.on(map);
-        final StrSubstitutor strSubstitutor = new 
StrSubstitutor(strLookupMapStrLookup);
+        final StringLookup mapStringLookup = 
StringLookupFactory.INSTANCE.mapStringLookup(map);
+        final StrSubstitutor strSubstitutor = new 
StrSubstitutor(mapStringLookup);
 
         assertNull(strSubstitutor.replace((CharSequence) null, 0, 0));
         assertEquals('$', strSubstitutor.getEscapeChar());
@@ -836,8 +835,8 @@ public class StrSubstitutorTest {
     @Test
     public void 
testCreatesStrSubstitutorTakingStrLookupAndCallsReplaceTakingTwoAndThreeInts_deprecated()
 {
         final Map<String, CharacterPredicates> map = new HashMap<>();
-        final StrLookup.MapStrLookup<CharacterPredicates> 
strLookupMapStrLookup = new StrLookup.MapStrLookup<>(map);
-        final StrSubstitutor strSubstitutor = new 
StrSubstitutor(strLookupMapStrLookup);
+        final StrLookup.MapStrLookup<CharacterPredicates> mapStrLookup = new 
StrLookup.MapStrLookup<>(map);
+        final StrSubstitutor strSubstitutor = new StrSubstitutor(mapStrLookup);
 
         assertNull(strSubstitutor.replace((CharSequence) null, 0, 0));
         assertEquals('$', strSubstitutor.getEscapeChar());

Reply via email to