CommonUtils { public static String join(Collection collection, String separator) { if (isEmpty(collection)) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Object object : collection) { if (object != null) { String string = StringUtils.toString(object); if (string != null) { sb.append(string).append(separator); } } } return sb.length() > 0 ? sb.substring(0, sb.length() - separator.length()) : StringUtils.EMPTY; }  static V putToConcurrentMap(ConcurrentMap<K, V> map, K key, V value); static boolean isTrue(String b); static boolean isTrue(Boolean b); static boolean isFalse(Boolean b); static boolean isFalse(String b); static boolean isEmpty(Collection collection); static boolean isNotEmpty(Collection collection); static boolean isEmpty(Map map); static boolean isNotEmpty(Map map); static boolean isEmpty(Object[] array); static boolean isNotEmpty(Object[] array); static T parseNum(T num, T defaultInt); static int parseInt(String num, int defaultInt); static long parseLong(String num, long defaultLong); static boolean parseBoolean(String bool, boolean defaultInt); static int[] parseInts(String nums, String sperator); static boolean listEquals(List<T> left, List<T> right); static String join(Collection collection, String separator);  }
@Test public void join() { Assert.assertEquals(CommonUtils.join(null, ","), ""); Assert.assertEquals(CommonUtils.join(new ArrayList(), ","), ""); List<String> s = new ArrayList<String>(); s.add("a"); s.add("b"); s.add("c"); Assert.assertEquals(CommonUtils.join(s, "1"), "a1b1c"); }