public static CharSequence join(CharSequence separator, Iterable<? extends CharSequence> elements) {
        ObjectUtil.checkNotNull(separator, "separator");
        ObjectUtil.checkNotNull(elements, "elements");

        Iterator<? extends CharSequence> iterator = elements.iterator();
        if (!iterator.hasNext()) {
            return EMPTY_STRING;
        }

        CharSequence firstElement = iterator.next();
        if (!iterator.hasNext()) {
            return firstElement;
        }

        StringBuilder builder = new StringBuilder(firstElement);
        do {
            builder.append(separator).append(iterator.next());
        } while (iterator.hasNext());

        return builder;
    }
@Test
    public void testJoin() {
        assertEquals("",
                     StringUtil.join(",", Collections.<CharSequence>emptyList()).toString());
        assertEquals("a",
                     StringUtil.join(",", Collections.singletonList("a")).toString());
        assertEquals("a,b",
                     StringUtil.join(",", Arrays.asList("a", "b")).toString());
        assertEquals("a,b,c",
                     StringUtil.join(",", Arrays.asList("a", "b", "c")).toString());
        assertEquals("a,b,c,null,d",
                     StringUtil.join(",", Arrays.asList("a", "b", "c", null, "d")).toString());
    }