Tools { public static String joinNonEmpty(String[] array, char separator) { boolean somethingAdded = false; StringBuilder sb = new StringBuilder(); for (String str : array) { if (StringUtils.isNotBlank(str)) { if (!somethingAdded) { somethingAdded = true; } else { sb.append(separator); } sb.append(str); } } return sb.toString(); } private  Tools(); static String toString(Object value); static String joinNonEmpty(String[] array, char separator); static String marshalToXml(Object obj, Class sourceClass); @SuppressWarnings("unchecked") static String marshalToXml(T obj, QName qName); @SuppressWarnings("unchecked") static T unmarshalFromXml(String xml, Class<T> targetClass); static OffsetDateTime toUTC(OffsetDateTime localDateTime); static OffsetDateTime fromUTC(OffsetDateTime utcTime); static OffsetDateTime fromUTC(long utcMillis); static Set<String> getAllKnownPropertyNames(ConfigurableEnvironment env); static Properties getPropertiesWithPrefix(ConfigurableEnvironment env, String propertyNamePrefix); static String fm(String message, Object... values);  }
@Test public void testJoinNonEmpty() { assertEquals("Separate this character", joinNonEmpty(new String[]{"", "Separate", "this", null, "character", "", null}, ' ')); assertEquals("", joinNonEmpty(new String[]{}, 'x')); assertEquals(" joinNonEmpty(new String[]{" assertEquals(" joinNonEmpty(new String[]{null, " assertEquals(" joinNonEmpty(new String[]{"/", "", "/", null}, '/')); assertEquals("/,2", joinNonEmpty(new String[]{"/", " ", "2", null}, ',')); }