Skip to content
Permalink
Browse files

Improved: Remove unused ‘StringUtil#appendTo’ methods

(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859934 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent 047340f commit 008fd8ded43385426c37649024e585dcdc8a6018
@@ -23,7 +23,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -36,7 +35,6 @@

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.ofbiz.base.lang.Appender;

/**
* Misc String Utility Functions
@@ -438,33 +436,6 @@ public static StringWrapper makeStringWrapper(String theString) {
return new StringWrapper(theString);
}

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

public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) {
Iterator<? extends Appender<StringBuilder>> it = iterable.iterator();
while (it.hasNext()) {
if (prefix != null) {
sb.append(prefix);
}
it.next().appendTo(sb);
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.
@@ -243,17 +243,4 @@ public StringBuilder appendTo(StringBuilder sb) {
return sb.append(s);
}
}

public void testAppendTo() {
assertEquals("111", "[1],[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", ",").toString());
assertEquals("011", "1],2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), null, "]", ",").toString());
assertEquals("101", "[1,[2", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", null, ",").toString());
assertEquals("110", "[1][2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", null).toString());
assertEquals("11111", "[1]<,>[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", ",", ">").toString());
assertEquals("01111", "1]<,>2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), null, "]", "<", ",", ">").toString());
assertEquals("10111", "[1<,>[2", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", null, "<", ",", ">").toString());
assertEquals("11011", "[1],>[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", null, ",", ">").toString());
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());
}
}

0 comments on commit 008fd8d

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