Skip to content
Permalink
Browse files

Improved: Remove unused ‘StringUtil#collapseCharacter’

(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859932 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent b871eda commit 047340f8a54f6283d46c4750496e2c33607e1dcf
@@ -425,28 +425,6 @@ public static String convertOperatorSubstitutions(String expression) {
return result;
}

/**
* Remove/collapse multiple characters
*
* @param str string to collapse characters in
* @param c character to collapse
* @return the converted string
*/
public static String collapseCharacter(String str, char c) {
StringBuilder sb = new StringBuilder();
char last = str.charAt(0);

for (int i = 0; i < str.length(); i++) {
char current = str.charAt(i);
if (i == 0 || current != c || last != c) {
sb.append(current);
last = current;
}
}

return sb.toString();
}

public static StringWrapper wrapString(String theString) {
return makeStringWrapper(theString);
}
@@ -225,12 +225,6 @@ public void testCollapseNewlines() {
public void testCollapseSpaces() {
}

public void testCollapseCharacter() {
assertEquals("not-found", "abcdefg", StringUtil.collapseCharacter("abcdefg", '.'));
assertEquals("no-change", "abcdefg", StringUtil.collapseCharacter("abcdefg", 'a'));
assertEquals("duplicate", "abcdefa", StringUtil.collapseCharacter("aabcdefaa", 'a'));
}

public void testWrapString() {
}

0 comments on commit 047340f

Please sign in to comment.
You can’t perform that action at this time.