@Test public void test_join_null() { String result = CollectionUtils.join(null, ","); Assertions.assertEquals("", result); }
public static String join(final Collection<?> coll, String separate) { if (isEmpty(coll)) { return ""; } StringBuilder buf = new StringBuilder(); coll.stream().filter(a -> a != null).forEach(o -> { if (o instanceof Character) { buf.append(separate).append((Character) o); } else if (o instanceof String) { if (StringUtils.isNotBlank((String) o)) { buf.append(separate).append((String) o); } } else { buf.append(separate).append(o.toString()); } }); if (buf.length() < separate.length()) { return ""; } else { return buf.substring(separate.length()); } }
CollectionUtils { public static String join(final Collection<?> coll, String separate) { if (isEmpty(coll)) { return ""; } StringBuilder buf = new StringBuilder(); coll.stream().filter(a -> a != null).forEach(o -> { if (o instanceof Character) { buf.append(separate).append((Character) o); } else if (o instanceof String) { if (StringUtils.isNotBlank((String) o)) { buf.append(separate).append((String) o); } } else { buf.append(separate).append(o.toString()); } }); if (buf.length() < separate.length()) { return ""; } else { return buf.substring(separate.length()); } } }
CollectionUtils { public static String join(final Collection<?> coll, String separate) { if (isEmpty(coll)) { return ""; } StringBuilder buf = new StringBuilder(); coll.stream().filter(a -> a != null).forEach(o -> { if (o instanceof Character) { buf.append(separate).append((Character) o); } else if (o instanceof String) { if (StringUtils.isNotBlank((String) o)) { buf.append(separate).append((String) o); } } else { buf.append(separate).append(o.toString()); } }); if (buf.length() < separate.length()) { return ""; } else { return buf.substring(separate.length()); } }  }
CollectionUtils { public static String join(final Collection<?> coll, String separate) { if (isEmpty(coll)) { return ""; } StringBuilder buf = new StringBuilder(); coll.stream().filter(a -> a != null).forEach(o -> { if (o instanceof Character) { buf.append(separate).append((Character) o); } else if (o instanceof String) { if (StringUtils.isNotBlank((String) o)) { buf.append(separate).append((String) o); } } else { buf.append(separate).append(o.toString()); } }); if (buf.length() < separate.length()) { return ""; } else { return buf.substring(separate.length()); } }  static boolean isEmpty(final Collection<?> coll); static boolean isNotEmpty(final Collection<?> coll); static String join(final Collection<?> coll, String separate); }
CollectionUtils { public static String join(final Collection<?> coll, String separate) { if (isEmpty(coll)) { return ""; } StringBuilder buf = new StringBuilder(); coll.stream().filter(a -> a != null).forEach(o -> { if (o instanceof Character) { buf.append(separate).append((Character) o); } else if (o instanceof String) { if (StringUtils.isNotBlank((String) o)) { buf.append(separate).append((String) o); } } else { buf.append(separate).append(o.toString()); } }); if (buf.length() < separate.length()) { return ""; } else { return buf.substring(separate.length()); } }  static boolean isEmpty(final Collection<?> coll); static boolean isNotEmpty(final Collection<?> coll); static String join(final Collection<?> coll, String separate);  }