### Question:
DocFormatter { public String format() { return format(DEFAULT_PART_FORMATTER); } DocFormatter(String doc); String getDoc(); List<Part> getParts(); String format(); String format(PartFormatter partFormatter); static String format(String doc); static String format(String doc, PartFormatter partFormatter);  }### Answer:
@Test public void testDocIsFormatted() throws Exception { String text = DocFormatter.format(null, ToStringPartFormatter.INSTANCE); Assert.assertNull(text); text = new DocFormatter("text{@link}text").format(p -> "X"); Assert.assertNotNull(text); Assert.assertEquals("XXX", text); text = new DocFormatter("text{@link}text").format(p -> { if (p instanceof Text) { return "-TEXT-"; } else if (p instanceof Tag) { return "-TAG-"; } else { return null; } }); Assert.assertNotNull(text); Assert.assertEquals("-TEXT--TAG--TEXT-", text); text = new DocFormatter("text{@link}text").format(p -> { if (p instanceof Text) { return p.toString(); } else if (p instanceof Tag) { return "-TAG-"; } else { return null; } }); Assert.assertNotNull(text); Assert.assertEquals("text-TAG-text", text); }