Skip to content

Commit 9e30ebe

Browse files
committed
fix delete unused method StringUtils.join(..)
Signed-off-by: WillardHu <[email protected]>
1 parent 0b5d227 commit 9e30ebe

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -344,44 +344,4 @@ public interface StringFormatter<T> {
344344
String format(T obj);
345345
}
346346

347-
public static <T> String join(Collection<T> collection, String separator) {
348-
return join(collection, separator, new StringFormatter<T>() {
349-
@Override
350-
public String format(T obj) {
351-
return obj.toString();
352-
}
353-
});
354-
}
355-
356-
public static <T> String join(Collection<T> collection, String separator,
357-
StringFormatter<T> formatter) {
358-
Iterator<T> iterator = collection.iterator();
359-
// handle null, zero and one elements before building a buffer
360-
if (iterator == null) {
361-
return null;
362-
}
363-
if (!iterator.hasNext()) {
364-
return EMPTY;
365-
}
366-
T first = iterator.next();
367-
if (!iterator.hasNext()) {
368-
return first == null ? "" : formatter.format(first);
369-
}
370-
371-
// two or more elements
372-
StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
373-
if (first != null) {
374-
buf.append(formatter.format(first));
375-
}
376-
377-
while (iterator.hasNext()) {
378-
buf.append(separator);
379-
T obj = iterator.next();
380-
if (obj != null) {
381-
buf.append(formatter.format(obj));
382-
}
383-
}
384-
385-
return buf.toString();
386-
}
387347
}

apollo-core/src/test/java/com/ctrip/framework/apollo/core/utils/StringUtilsTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ public void testIsNumeric() {
6868
Assert.assertTrue(StringUtils.isNumeric("1"));
6969
}
7070

71-
@Test
72-
public void testJoin() {
73-
Assert.assertEquals("", StringUtils.join(new ArrayList(), "1a 2b 3c"));
74-
75-
ArrayList collection = new ArrayList();
76-
collection.add(null);
77-
Assert.assertEquals("", StringUtils.join(collection, "1a 2b 3c"));
78-
79-
collection = new ArrayList();
80-
collection.add(-2_147_483_648);
81-
Assert.assertEquals("-2147483648", StringUtils.join(collection, "1a 2b 3c"));
82-
}
83-
8471
@Test
8572
public void testStartsWithIgnoreCase() {
8673
Assert.assertFalse(StringUtils.startsWithIgnoreCase("A1B2C3", "BAZ"));

0 commit comments

Comments
 (0)