ArrayUtil { public static Object[] expand(Object... params) { int length = params.length; for (Object object : params) { if (object instanceof Object[]) { length = length + ((Object[]) object).length - 1; } } Object[] result = new Object[length]; int destIndex = 0; for (Object param : params) { if (param instanceof Object[]) { int srcLength = ((Object[]) param).length; System.arraycopy(param, 0, result, destIndex, srcLength); destIndex += srcLength; } else { result[destIndex++] = param; } } return result; }  static void addNoExists(List<T> dest, List<T> src); static Object[] expand(Object... params); static boolean containsNotNull(Object[] array);  }
@Test public void testExpand() { Object[] result = ArrayUtil.expand(1L); assertEquals(1, result.length); assertEquals(1L, result[0]); result = ArrayUtil.expand(1L, 2L); assertEquals(2, result.length); assertEquals(1L, result[0]); assertEquals(2L, result[1]); result = ArrayUtil.expand(1L, new Object[] { 3L, 4L }, 2L); assertEquals(4, result.length); assertEquals(1L, result[0]); assertEquals(3L, result[1]); assertEquals(4L, result[2]); assertEquals(2L, result[3]); result = ArrayUtil.expand(1L); assertEquals(1, result.length); assertEquals(1L, result[0]); result = ArrayUtil.expand(); assertEquals(0, result.length); }