Dropping the concat methods. Moving the join(Object[]) to join(Object...). LANG-396. LANG-683.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1079173 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2011-03-08 05:34:01 +00:00
parent 3456b2b6b1
commit 8542ccb689
2 changed files with 7 additions and 56 deletions

View File

@ -3177,48 +3177,6 @@ private static String[] splitByCharacterType(String str, boolean camelCase) {
// Joining // Joining
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/**
* <p>Joins the provided elements into a single String. </p>
*
* <p>No separator is added to the joined String.
* Null objects or empty string elements are represented by
* empty strings.</p>
*
* <pre>
* StringUtils.concat("a", "b", "c") = "abc"
* StringUtils.concat(null, "", "a") = "a"
* </pre>
*
* @param elements the values to join together
* @return the concatenated String
* @since 3.0
*/
public static String concat(Object... elements) {
return join(elements, null);
}
/**
* <p>Joins the provided elements into a single String, with the specified
* separator between each element. </p>
*
* <p>No separator is added before or after the joined String.
* Null objects or empty string elements are represented by
* empty strings.</p>
*
* <pre>
* StringUtils.concatWith(".", "a", "b", "c") = "a.b.c"
* StringUtils.concatWith("", null, "", "a") = "a"
* </pre>
*
* @param separator the value to put between elements
* @param elements the values to join together
* @return the concatenated String
* @since 3.0
*/
public static String concatWith(String separator, Object... elements) {
return join(elements, separator);
}
/** /**
* <p>Joins the elements of the provided array into a single String * <p>Joins the elements of the provided array into a single String
* containing the provided list of elements.</p> * containing the provided list of elements.</p>
@ -3238,9 +3196,10 @@ public static String concatWith(String separator, Object... elements) {
* @param array the array of values to join together, may be null * @param array the array of values to join together, may be null
* @return the joined String, {@code null} if null array input * @return the joined String, {@code null} if null array input
* @since 2.0 * @since 2.0
* @since 3.0 Changed signature to use varargs
*/ */
public static String join(Object[] array) { public static String join(Object... elements) {
return join(array, null); return join(elements, null);
} }
/** /**

View File

@ -188,18 +188,10 @@ public void testSwapCase_String() {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testConcat_Objects() { public void testJoin_Objects() {
assertEquals("abc", StringUtils.concat("a", "b", "c")); assertEquals("abc", StringUtils.join("a", "b", "c"));
assertEquals("a", StringUtils.concat(null, "", "a")); assertEquals("a", StringUtils.join(null, "", "a"));
assertEquals(null, StringUtils.concat((Object[])null)); assertEquals(null, StringUtils.join((Object[])null));
}
public void testConcatWith_StringObjects() {
assertEquals("a.b.c", StringUtils.concatWith(".", "a", "b", "c"));
assertEquals("a...b...c", StringUtils.concatWith("...", "a", "b", "c"));
assertEquals("a", StringUtils.concatWith("", null, "", "a"));
assertEquals("a", StringUtils.concatWith(null, null, "", "a"));
assertEquals(null, StringUtils.concatWith(null, (Object[])null));
} }
public void testJoin_Objectarray() { public void testJoin_Objectarray() {