Fix code duplication
This commit is contained in:
parent
dc8920206e
commit
c18803a47f
|
@ -654,7 +654,6 @@ public class WordUtils {
|
||||||
boolean lastWasGap = true;
|
boolean lastWasGap = true;
|
||||||
for (int i = 0; i < strLen; i++) {
|
for (int i = 0; i < strLen; i++) {
|
||||||
final char ch = str.charAt(i);
|
final char ch = str.charAt(i);
|
||||||
|
|
||||||
if (isDelimiter(ch, delimiters)) {
|
if (isDelimiter(ch, delimiters)) {
|
||||||
lastWasGap = true;
|
lastWasGap = true;
|
||||||
} else if (lastWasGap) {
|
} 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 ch the character to check
|
||||||
* @param delimiters the delimiters
|
* @param delimiters the delimiters
|
||||||
* @return true if it is a delimiter
|
* @return true if it is a delimiter
|
||||||
*/
|
*/
|
||||||
private static boolean isDelimiter(final char ch, final char[] delimiters) {
|
private static boolean isDelimiter(final char ch, final char[] delimiters) {
|
||||||
if (delimiters == null) {
|
return delimiters == null ? Character.isWhitespace(ch) : ArrayUtils.contains(delimiters, ch);
|
||||||
return Character.isWhitespace(ch);
|
|
||||||
}
|
|
||||||
for (final char delimiter : delimiters) {
|
|
||||||
if (ch == delimiter) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue