1 package com.atlassian.core.util.collection;
2
3 import org.apache.commons.lang.StringUtils;
4
5 /**
6 * Collection of useful Array methods
7 */
8 public class ArrayUtils
9 {
10 /**
11 * Adds a string to an array and resizes the array. Method is null safe.
12 * @param array - original array
13 * @param obj - String to add
14 * @return an array with the new straing addded to the end
15 *
16 * @deprecated use Guava's {@code ObjectArrays.concat()}
17 */
18 @Deprecated
19 public static String[] add(String[] array, String obj)
20 {
21 if (array != null)
22 {
23 String[] newArray = new String[array.length + 1];
24 System.arraycopy(array, 0, newArray, 0, array.length);
25 newArray[array.length] = obj;
26
27 return newArray;
28 }
29 else if (obj != null)
30 {
31 return new String[]{obj};
32 }
33 else
34 {
35 return null;
36 }
37 }
38
39 /**
40 * Checks if the array is not null, and contains one and only one element, which is blank (see {@link StringUtils#isBlank})
41 * @param array
42 * @return true or false
43 */
44 public static boolean isContainsOneBlank(String[] array)
45 {
46 return array != null && array.length == 1 && StringUtils.isBlank(array[0]);
47 }
48 }