StringUtil { public static String merge(boolean[] array, String delimiter) { if (array == null) { return null; } if (array.length == 0) { return StringPool.BLANK; } if (array.length == 1) { return String.valueOf(array[0]); } StringBundler sb = new StringBundler(2 * array.length); for (int i = 0; i < array.length; i++) { sb.append(array[i]); sb.append(delimiter); } sb.setIndex(sb.index() - 1); return sb.toString(); }  static String merge(boolean[] array, String delimiter); static String merge(byte[] array, String delimiter); static String merge(char[] array, String delimiter); static String merge(
		Collection<T> col, Function<T, String> toStringFunction,
		String delimiter); static String merge(Collection<T> col, String delimiter); static String merge(double[] array, String delimiter); static String merge(float[] array, String delimiter); static String merge(int[] array, String delimiter); static String merge(
		L list, Function<T, String> toStringFunction, String delimiter); static String merge(
		L list, String delimiter); static String merge(long[] array, String delimiter); static String merge(short[] array, String delimiter); static String merge(String[] array, String delimiter); static String merge(
		T[] array, Function<T, String> toStringFunction, String delimiter); static String merge(T[] array, String delimiter); static List<String> split(String s); static List<String> split(String s, char delimiter);  }
@Test public void testMerge() { Assert.assertNull(StringUtil.merge((boolean[])null, null)); Assert.assertNull(StringUtil.merge((byte[])null, null)); Assert.assertNull(StringUtil.merge((char[])null, null)); Assert.assertNull(StringUtil.merge((double[])null, null)); Assert.assertNull(StringUtil.merge((float[])null, null)); Assert.assertNull(StringUtil.merge((int[])null, null)); Assert.assertNull(StringUtil.merge((long[])null, null)); Assert.assertNull(StringUtil.merge((short[])null, null)); Assert.assertNull(StringUtil.merge((String[])null, null)); Assert.assertNull(StringUtil.merge((Object[])null, null)); Assert.assertNull(StringUtil.merge((Object[])null, null, null)); Assert.assertNull(StringUtil.merge((ArrayList<Object>)null, null)); Assert.assertNull( StringUtil.merge((ArrayList<Object>)null, null, null)); Assert.assertNull(StringUtil.merge((Collection<Object>)null, null)); Assert.assertNull( StringUtil.merge((Collection<Object>)null, null, null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new boolean[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new byte[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new char[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new double[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new float[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new int[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new long[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new short[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new String[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new Object[0], null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new Object[0], null, null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new ArrayList<>(), null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new ArrayList<>(), null, null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new LinkedList<>(), null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new LinkedList<>(), null, null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(Arrays.asList(), null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(Arrays.asList(), null, null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new HashSet<>(), null)); Assert.assertEquals( StringPool.BLANK, StringUtil.merge(new HashSet<>(), null, null)); Assert.assertEquals( StringPool.TRUE, StringUtil.merge(new boolean[] {true}, null)); Assert.assertEquals("1", StringUtil.merge(new byte[] {1}, null)); Assert.assertEquals("a", StringUtil.merge(new char[] {'a'}, null)); Assert.assertEquals("1.2", StringUtil.merge(new double[] {1.2D}, null)); Assert.assertEquals("1.0", StringUtil.merge(new float[] {1.0F}, null)); Assert.assertEquals("2", StringUtil.merge(new int[] {2}, null)); Assert.assertEquals("3", StringUtil.merge(new long[] {3L}, null)); Assert.assertEquals("4", StringUtil.merge(new short[] {4}, null)); Assert.assertEquals( "abc", StringUtil.merge(new String[] {"abc"}, null)); Assert.assertEquals("4", StringUtil.merge(new Object[] {4}, null)); Assert.assertEquals( "5x", StringUtil.merge( new Object[] {5}, object -> object.toString() + "x", null)); Assert.assertEquals( "a", StringUtil.merge(new ArrayList<>(Arrays.asList("a")), null)); Assert.assertEquals( "ax", StringUtil.merge( new ArrayList<>(Arrays.asList("a")), s -> s + "x", null)); Assert.assertEquals("a", StringUtil.merge(Arrays.asList("a"), null)); Assert.assertEquals( "ax", StringUtil.merge(Arrays.asList("a"), s -> s + "x", null)); Assert.assertEquals( "a", StringUtil.merge(new HashSet<>(Arrays.asList("a")), null)); Assert.assertEquals( "ax", StringUtil.merge( new HashSet<>(Arrays.asList("a")), s -> s + "x", null)); Assert.assertEquals( "true,false", StringUtil.merge(new boolean[] {true, false}, StringPool.COMMA)); Assert.assertEquals( "1,2", StringUtil.merge(new byte[] {1, 2}, StringPool.COMMA)); Assert.assertEquals( "a,b", StringUtil.merge(new char[] {'a', 'b'}, StringPool.COMMA)); Assert.assertEquals( "1.2,3.4", StringUtil.merge(new double[] {1.2D, 3.4D}, StringPool.COMMA)); Assert.assertEquals( "1.0,2.0", StringUtil.merge(new float[] {1.0F, 2.0F}, StringPool.COMMA)); Assert.assertEquals( "2,3", StringUtil.merge(new int[] {2, 3}, StringPool.COMMA)); Assert.assertEquals( "3,4", StringUtil.merge(new long[] {3L, 4L}, StringPool.COMMA)); Assert.assertEquals( "4,5", StringUtil.merge(new short[] {4, 5}, StringPool.COMMA)); Assert.assertEquals( "abc,def", StringUtil.merge(new String[] {"abc", "def"}, StringPool.COMMA)); Assert.assertEquals( "4,x", StringUtil.merge(new Object[] {4, "x"}, StringPool.COMMA)); Assert.assertEquals( "5x,ax", StringUtil.merge( new Object[] {5, 'a'}, object -> object.toString() + "x", StringPool.COMMA)); Assert.assertEquals( "a,b", StringUtil.merge( new ArrayList<>(Arrays.asList("a", "b")), StringPool.COMMA)); Assert.assertEquals( "ax,bx", StringUtil.merge( new ArrayList<>(Arrays.asList("a", "b")), s -> s + "x", StringPool.COMMA)); Assert.assertEquals( "a,b", StringUtil.merge(Arrays.asList("a", "b"), StringPool.COMMA)); Assert.assertEquals( "ax,bx", StringUtil.merge( Arrays.asList("a", "b"), s -> s + "x", StringPool.COMMA)); Assert.assertEquals( "a,b", StringUtil.merge( new HashSet<>(Arrays.asList("a", "b")), StringPool.COMMA)); Assert.assertEquals( "ax,bx", StringUtil.merge( new HashSet<>(Arrays.asList("a", "b")), s -> s + "x", StringPool.COMMA)); }