Skip to content
Permalink
Browse files

Improved: Remove unused ‘StringUtil#append’ method

(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859922 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent d886fd1 commit d7aab2ff7359c42dc5e5f4f24c3c75a36d9e8d72
@@ -627,33 +627,6 @@ public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Append
return sb;
}

public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sep) {
return append(sb, iterable, prefix, suffix, null, sep, null);
}

public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) {
Iterator<? extends Object> it = iterable.iterator();
while (it.hasNext()) {
if (prefix != null) {
sb.append(prefix);
}
sb.append(it.next());
if (suffix != null) {
sb.append(suffix);
}
if (it.hasNext() && sep != null) {
if (sepPrefix != null) {
sb.append(sepPrefix);
}
sb.append(sep);
if (sepSuffix != null) {
sb.append(sepSuffix);
}
}
}
return sb;
}

/**
* A super-lightweight object to wrap a String object. Mainly used with FTL templates
* to avoid the general HTML auto-encoding that is now done through the Screen Widget.
@@ -307,17 +307,4 @@ public void testAppendTo() {
assertEquals("11101", "[1][2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", null, ">").toString());
assertEquals("11110", "[1]<,[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", ",", null).toString());
}

public void testAppend() {
assertEquals("111", "[1],[2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", ",").toString());
assertEquals("011", "1],2]", StringUtil.append(new StringBuilder(), list("1", "2"), null, "]", ",").toString());
assertEquals("101", "[1,[2", StringUtil.append(new StringBuilder(), list("1", "2"), "[", null, ",").toString());
assertEquals("110", "[1][2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", null).toString());
assertEquals("11111", "[1]<,>[2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", "<", ",", ">").toString());
assertEquals("01111", "1]<,>2]", StringUtil.append(new StringBuilder(), list("1", "2"), null, "]", "<", ",", ">").toString());
assertEquals("10111", "[1<,>[2", StringUtil.append(new StringBuilder(), list("1", "2"), "[", null, "<", ",", ">").toString());
assertEquals("11011", "[1],>[2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", null, ",", ">").toString());
assertEquals("11101", "[1][2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", "<", null, ">").toString());
assertEquals("11110", "[1]<,[2]", StringUtil.append(new StringBuilder(), list("1", "2"), "[", "]", "<", ",", null).toString());
}
}

0 comments on commit d7aab2f

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