LANG-1606 StringUtils.countMatches - fix Javadoc

This commit is contained in:
Sebb 2020-09-12 23:23:18 +01:00
parent 0054e51500
commit 38a9209456
3 changed files with 12 additions and 1 deletions

View File

@ -51,6 +51,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1600" type="fix" dev="ggregory" due-to="Michael F">Restore handling of collections for non-JSON ToStringStyle #610.</action>
<action type="fix" dev="ggregory" due-to="iamchao1129">ContextedException Javadoc add missing semicolon #581.</action>
<!-- UPDATES -->
<action issue="LANG-1606" type="update" dev="sebb" due-to="Rustem Galiev">StringUtils.countMatches - clarify Javadoc.</action>
<action issue="LANG-1591" type="update" dev="kinow" due-to="bhawna94">Remove redundant argument from substring call.</action>
<action issue="LANG-1579" type="update" dev="aherbert" due-to="XenoAmess">Improve StringUtils.stripAccents conversion of remaining accents.</action>
<action issue="LANG-1596" type="update" dev="aherbert" due-to="Richard Eckart de Castilho">ArrayUtils.toPrimitive(Object) does not support boolean and other types #607.</action>

View File

@ -1425,7 +1425,8 @@ public class StringUtils {
// Count matches
//-----------------------------------------------------------------------
/**
* <p>Counts how many times the substring appears in the larger string.</p>
* <p>Counts how many times the substring appears in the larger string.
* Note that the code only counts non-overlapping matches.</p>
*
* <p>A {@code null} or empty ("") String input returns {@code 0}.</p>
*
@ -1437,6 +1438,7 @@ public class StringUtils {
* StringUtils.countMatches("abba", "a") = 2
* StringUtils.countMatches("abba", "ab") = 1
* StringUtils.countMatches("abba", "xxx") = 0
* StringUtils.countMatches("ababa", "aba") = 1
* </pre>
*
* @param str the CharSequence to check, may be null

View File

@ -349,6 +349,14 @@ public class StringUtilsSubstringTest {
StringUtils.countMatches("one long someone sentence of one", "two"));
assertEquals(4,
StringUtils.countMatches("oooooooooooo", "ooo"));
assertEquals(0, StringUtils.countMatches(null, "?"));
assertEquals(0, StringUtils.countMatches("", "?"));
assertEquals(0, StringUtils.countMatches("abba", null));
assertEquals(0, StringUtils.countMatches("abba", ""));
assertEquals(2, StringUtils.countMatches("abba", "a"));
assertEquals(1, StringUtils.countMatches("abba", "ab"));
assertEquals(0, StringUtils.countMatches("abba", "xxx"));
assertEquals(1, StringUtils.countMatches("ababa", "aba"));
}
@Test