Joiners { public static StringJoiner by(final char delimiter) { return new StringJoiner() { @Override protected void appendDelimiter(StringBuilder sb) { sb.append(delimiter); } }; }  static StringJoiner by(final char delimiter); static StringJoiner by(final String delimiter);  }
@Test public void testJoin() { Assert.assertNull(Joiners.by(",").join(null, null)); Assert.assertTrue(Joiners.by(",").prefixDelimiter() instanceof StringJoiner); Assert.assertTrue(Joiners.by(",").noEmptyItem() instanceof StringJoiner); String noPrefixStr = Joiners.by(",").join("one", "two", "three"); String prefixStr = Joiners.by(",").prefixDelimiter().join("one", "two", "three"); Assert.assertEquals("," + noPrefixStr, prefixStr); String emptyStr = Joiners.by(",").join("one", "two", "three", null); String noEmptyStr = Joiners.by(",").noEmptyItem().join("one", "two", "three", null); Assert.assertEquals(emptyStr, noEmptyStr+",null"); }