void configure(TableModel model) {
        numColumns = 0;

        model.table().columnKeySet().stream().forEach(columnKey -> {
            if (!columnFormatters.containsKey(columnKey)) {
                columnFormatters.put(columnKey, String::valueOf);
            }

            // set minimum column width if not already defined
            if (!columnWidths.containsKey(columnKey)) {
                columnWidths.put(columnKey, model.table()
                    .column(columnKey)
                    .values()
                    .stream()
                    .map(columnFormatters.get(columnKey))
                    .mapToInt(String::length)
                    .max()
                    .getAsInt()
                );
            }

            if (!columnAlignments.containsKey(columnKey)
                    || columnAlignments.get(columnKey) == TextTableAlignment.AUTO) {
                // count class types
                Map<Class, Long> columnTypeMap = model.table()
                    .column(columnKey)
                    .values()
                    .stream()
                    .skip(model.columnHeader() ? 1 : 0) // don't include type of column header
                    .map(Object::getClass)
                    .collect(Collectors.groupingBy(o -> o, Collectors.counting()));

                // get most occurring class
                Optional<Map.Entry<Class, Long>> topClassEntry = columnTypeMap
                    .entrySet()
                    .stream()
                    .max((v1, v2) -> Long.compare(v1.getValue(), v2.getValue()));

                Class columnType = Object.class;

                if (topClassEntry.isPresent()) {
                    columnType = topClassEntry.get().getKey();
                }

                // align number columns to the right for better readability
                boolean isNumber = Number.class.isAssignableFrom(columnType);
                TextTableAlignment align;

                if (isNumber) {
                    align = TextTableAlignment.RIGHT;
                } else {
                    align = TextTableAlignment.LEFT;
                }

                columnAlignments.put(columnKey, align);
            }

            numColumns++;
        });
    }
@author Nico Bergemann <barracuda415 at yahoo.de>
disunity-cli/src/main/java/info/ata4/disunity/cli/util/TextTableFormat.java