AsciiTable { public static <T> TableBuilder<T> builder(final Collection<T> data) { return new TableBuilder<T>(data); } private  AsciiTable(); static TableBuilder<T> builder(final Collection<T> data); static String from(final Collection<T> data);  }
@Test void test() { final List<Pojo> sourceData = List.of( new Pojo("Mr", "Joe", "Bloggs", LocalDate.of(1971, 3, 23), 180), new Pojo("Mrs", "Joanna", "Bloggs", LocalDate.of(1972, 4, 1), 170), new Pojo("Mr", "No Surname", null, LocalDate.of(1972, 4, 1), 170), new Pojo("Mrs", "Magdalena Clementine", "Fotherington-Smythe", LocalDate.of(1971, 3, 6), 166) ); final String table = AsciiTable.builder(sourceData) .withColumn(Column.of("Title", Pojo::getTitle)) .withColumn(Column.of("First Name", Pojo::getFirstName)) .withColumn(Column.builder("Surname", Pojo::getSurname) .withNullValueSupplier(() -> "-") .build()) .withColumn(Column.builder("Date of Birth", Pojo::getDob) .centerAligned() .build()) .withColumn(Column.builder("Height", Pojo::getHeightCm) .rightAligned() .withFormat(val -> val + "cm") .build()) .withRowLimit(100) .build(); LOGGER.info("table:\n{}", table); }