Renamed ArrayUtils.join(Object[],Object[]) to addAll.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2004-01-31 20:12:16 +00:00
parent fa5cac4449
commit 7cacd4f813
2 changed files with 24 additions and 24 deletions

View File

@ -81,7 +81,7 @@ import org.apache.commons.lang.builder.ToStringStyle;
* @author Gary Gregory
* @author <a href="mailto:equinus100@hotmail.com">Ashwin S</a>
* @since 2.0
* @version $Id: ArrayUtils.java,v 1.38 2004/01/31 09:57:39 scolebourne Exp $
* @version $Id: ArrayUtils.java,v 1.39 2004/01/31 20:12:16 ggregory Exp $
*/
public class ArrayUtils {
@ -2753,26 +2753,26 @@ public class ArrayUtils {
}
/**
* <p>Joins the elements of the provided arrays into a single new array.</p>
* <p>The new array contains all of the element of the first array followed
* by all of the elements from the second array.</p>
* <p>Adds all the elements of the provided arrays into a new array.</p>
* <p>The new array contains all of the element of <code>array1</code> followed
* by all of the elements <code>array2</code>.</p>
*
* <pre>
* ArrayUtils.join(null, null) = null
* ArrayUtils.join(array1, null) = array1
* ArrayUtils.join(null, array2) = array2
* ArrayUtils.join([], []) = []
* ArrayUtils.join([null], [null]) = [null, null]
* ArrayUtils.join(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
* ArrayUtils.addAll(null, null) = null
* ArrayUtils.addAll(array1, null) = array1
* ArrayUtils.addAll(null, array2) = array2
* ArrayUtils.addAll([], []) = []
* ArrayUtils.addAll([null], [null]) = [null, null]
* ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
* </pre>
*
* @param array1 the first array of values to join together, may be null
* @param array2 the second array of values to join together, may be null
* @return The new joined array, <code>null</code> if null array inputs.
* The type of the joined array is the type of the first array.
* @param array1 the first array whose elements are added to the new array, may be null
* @param array2 the second array whose elements are added to the new array, may be null
* @return The new array, <code>null</code> if null array inputs.
* The type of the new array is the type of the first array.
* @since 2.1
*/
public static Object[] join(Object[] array1, Object[] array2) {
public static Object[] addAll(Object[] array1, Object[] array2) {
if (array1 == null) {
return array2;
} else if (array2 == null) {

View File

@ -75,7 +75,7 @@ import junit.textui.TestRunner;
* @author <a href="mailto:equinus100@hotmail.com">Ashwin S</a>
* @author Fredrik Westermarck
* @author Gary Gregory
* @version $Id: ArrayUtilsTest.java,v 1.22 2004/01/30 01:39:57 ggregory Exp $
* @version $Id: ArrayUtilsTest.java,v 1.23 2004/01/31 20:12:15 ggregory Exp $
*/
public class ArrayUtilsTest extends TestCase {
@ -116,35 +116,35 @@ public class ArrayUtilsTest extends TestCase {
}
public void testJoin() {
assertNull(ArrayUtils.join(null, null));
assertNull(ArrayUtils.addAll(null, null));
Object[] joinedArray;
String[] stringArray1 = new String[]{"a", "b", "c"};
String[] stringArray2 = new String[]{"1", "2", "3"};
joinedArray = ArrayUtils.join(stringArray1, null);
joinedArray = ArrayUtils.addAll(stringArray1, null);
assertArraysEquals(stringArray1, joinedArray);
assertArraysEquals(new String[]{"a", "b", "c"}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
joinedArray = ArrayUtils.join(null, stringArray2);
joinedArray = ArrayUtils.addAll(null, stringArray2);
assertArraysEquals(stringArray2, joinedArray);
assertArraysEquals(new String[]{"1", "2", "3"}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
joinedArray = ArrayUtils.join(stringArray1, stringArray2);
joinedArray = ArrayUtils.addAll(stringArray1, stringArray2);
assertArraysEquals(new String[]{"a", "b", "c", "1", "2", "3"}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
joinedArray = ArrayUtils.join(ArrayUtils.EMPTY_STRING_ARRAY, null);
joinedArray = ArrayUtils.addAll(ArrayUtils.EMPTY_STRING_ARRAY, null);
assertArraysEquals(ArrayUtils.EMPTY_STRING_ARRAY, joinedArray);
assertArraysEquals(new String[]{}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
joinedArray = ArrayUtils.join(null, ArrayUtils.EMPTY_STRING_ARRAY);
joinedArray = ArrayUtils.addAll(null, ArrayUtils.EMPTY_STRING_ARRAY);
assertArraysEquals(ArrayUtils.EMPTY_STRING_ARRAY, joinedArray);
assertArraysEquals(new String[]{}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
joinedArray = ArrayUtils.join(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
joinedArray = ArrayUtils.addAll(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
assertArraysEquals(ArrayUtils.EMPTY_STRING_ARRAY, joinedArray);
assertArraysEquals(new String[]{}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
String[] stringArrayNull = new String []{null};
joinedArray = ArrayUtils.join(stringArrayNull, stringArrayNull);
joinedArray = ArrayUtils.addAll(stringArrayNull, stringArrayNull);
assertArraysEquals(new String[]{null, null}, joinedArray);
assertEquals(String.class, joinedArray.getClass().getComponentType());
}