FormatUtil { public static String join(String delimiter, Object... texts) { StringBuilder result = new StringBuilder(); for (Object text : texts) { if (text != null && isNotBlank(text.toString())) { result.append(text.toString()); result.append(delimiter); } } if (result.length() > 0) { return result.substring(0, result.length() - delimiter.length()); } else { return result.toString(); } } private  FormatUtil(); static String arrayToString(Object[] o); static String collectionToString(Collection<?> c); static String addDot(String text); static String join(String delimiter, Object... texts); static String fixLineSeparator(String str);  }
@Test public void join() { assertThat(FormatUtil.join("")).isEqualTo(""); assertThat(FormatUtil.join(", ")).isEqualTo(""); assertThat(FormatUtil.join(", ", null, null)).isEqualTo(""); assertThat(FormatUtil.join(", ", "1")).isEqualTo("1"); assertThat(FormatUtil.join(", ", "1", null, "2", " ", "3")).isEqualTo("1, 2, 3"); }