KeyValueFormatter implements KeyValueHandler { public void done() { if (haveSeenValues) { out.append(suffix); } } KeyValueFormatter(String prefix, String suffix, StringBuilder out); @Override void handle(String label, @NullableDecl Object value); void done();  }
@Test public void testNoValues() { StringBuilder out = new StringBuilder(); formatter(out).done(); assertThat(out.toString()).isEmpty(); out = new StringBuilder("Hello World"); formatter(out).done(); assertThat(out.toString()).isEqualTo("Hello World"); }