Fix code duplication

This commit is contained in:
Gary Gregory 2022-06-14 08:44:11 -04:00
parent dc8920206e
commit c18803a47f
1 changed files with 2 additions and 11 deletions

View File

@ -654,7 +654,6 @@ public class WordUtils {
boolean lastWasGap = true;
for (int i = 0; i < strLen; i++) {
final char ch = str.charAt(i);
if (isDelimiter(ch, delimiters)) {
lastWasGap = true;
} else if (lastWasGap) {
@ -707,22 +706,14 @@ public class WordUtils {
}
/**
* Is the character a delimiter.
* Tests if the character is a delimiter.
*
* @param ch the character to check
* @param delimiters the delimiters
* @return true if it is a delimiter
*/
private static boolean isDelimiter(final char ch, final char[] delimiters) {
if (delimiters == null) {
return Character.isWhitespace(ch);
}
for (final char delimiter : delimiters) {
if (ch == delimiter) {
return true;
}
}
return false;
return delimiters == null ? Character.isWhitespace(ch) : ArrayUtils.contains(delimiters, ch);
}
}