Move new method to tests since it is only used there is not generally
handy.
diff --git a/src/main/java/org/apache/commons/text/StringSubstitutor.java b/src/main/java/org/apache/commons/text/StringSubstitutor.java
index 6b6ebae..0400c43 100644
--- a/src/main/java/org/apache/commons/text/StringSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StringSubstitutor.java
@@ -603,19 +603,6 @@
}
/**
- * Gets the minimum expression length based on the size of the prefix matcher and suffix matcher.
- * <p>
- * By default, {@code 4}, as the shortest variable name length is 1, for example, {@code "${k}"}.
- * </p>
- *
- * @return the minimum expression length.
- * @since 1.9
- */
- public int getMinExpressionLength() {
- return getVariablePrefixMatcher().size() + 1 + getVariableSuffixMatcher().size();
- }
-
- /**
* Gets the StringLookup that is used to lookup variables.
*
* @return The StringLookup
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
index e5cc903..b4a7446 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
@@ -227,21 +227,6 @@
target.getValueDelimiterMatcher().toString());
}
- @Test
- public void testGetMinExpressionLength() throws IOException {
- final StringSubstitutor sub = new StringSubstitutor();
- assertEquals(4, sub.getMinExpressionLength());
- sub.setVariablePrefix('a');
- assertEquals(3, sub.getMinExpressionLength());
- sub.setVariablePrefix("abc");
- assertEquals(5, sub.getMinExpressionLength());
- sub.setVariableSuffix("xyz");
- assertEquals(7, sub.getMinExpressionLength());
- sub.setVariablePrefix(StringUtils.EMPTY);
- sub.setVariableSuffix(StringUtils.EMPTY);
- assertEquals(1, sub.getMinExpressionLength());
- }
-
/**
* Tests get set.
*/
diff --git a/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java b/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
index fd246b8..bdae41d 100644
--- a/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
+++ b/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
@@ -183,6 +183,10 @@
assertEquals(Objects.toString(expectedResult, StringUtils.EMPTY), actualResultWriter.toString());
}
+ private int getMinExpressionLength(final StringSubstitutor substitutor) {
+ return substitutor.getVariablePrefixMatcher().size() + 1 + substitutor.getVariableSuffixMatcher().size();
+ }
+
@Override
protected String replace(final StringSubstitutor substitutor, final String source) throws IOException {
if (source == null) {
@@ -197,7 +201,7 @@
public void testReadMixedBufferLengths1ToVarLenPlusNoReplace() throws IOException {
final StringSubstitutor substitutor = new StringSubstitutor(values);
final String template = "123456";
- assertTrue(template.length() > substitutor.getMinExpressionLength() + 1);
+ assertTrue(template.length() > getMinExpressionLength(substitutor) + 1);
try (Reader reader = createReader(substitutor, template)) {
assertEquals('1', reader.read());
final char[] cbuf = new char[template.length() - 1];
@@ -225,7 +229,7 @@
public void testReadMixedBufferLengthsVarLenPlusToNoReplace() throws IOException {
final StringSubstitutor substitutor = new StringSubstitutor(values);
final String template = "123456";
- assertTrue(template.length() > substitutor.getMinExpressionLength() + 1);
+ assertTrue(template.length() > getMinExpressionLength(substitutor) + 1);
try (Reader reader = createReader(substitutor, template)) {
final int endIndex = template.length() - 1;
final char[] cbuf = new char[endIndex];