AsciiTable { public static <T> String from(final Collection<T> data) { if (data.size() <= 1) { throw new RuntimeException("Need at least one row to auto create a table"); } final T item = data.iterator().next(); final TableBuilder<T> tableBuilder = builder(data); for (final Method method : item.getClass().getDeclaredMethods()) { final String methodName = method.getName(); if (methodName.startsWith("get") || methodName.startsWith("is")) { final Column<T, ?> column = convertToColumn(method); tableBuilder.withColumn(column); } } return tableBuilder.build(); } private  AsciiTable(); static TableBuilder<T> builder(final Collection<T> data); static String from(final Collection<T> data);  }
@Test void testAuto() { 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) ); final String table = AsciiTable.from(sourceData); LOGGER.info("table:\n{}", table); }