Class TableFormatter<T>


  • public class TableFormatter<T>
    extends java.lang.Object
    Mechanism for outputting tabular data to a stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      TableFormatter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addColumn​(java.lang.String title, java.util.function.Function<T,​java.lang.String> valueGetter, int prefixLimit, int suffixLimit)
      Adds a column to be printed in this table.
      void print​(java.util.Collection<T> values, java.io.PrintStream out)
      Print out a table with the given values to the given stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TableFormatter

        public TableFormatter()
    • Method Detail

      • addColumn

        public void addColumn​(@NonNull
                              java.lang.String title,
                              @NonNull
                              java.util.function.Function<T,​java.lang.String> valueGetter,
                              int prefixLimit,
                              int suffixLimit)
        Adds a column to be printed in this table.
        Parameters:
        title - The title to be shown at the top of the column.
        valueGetter - Function returning the value to be shown in the column.
        prefixLimit - Max characters to show before "..." if the value is long.
        suffixLimit - Max characters to show after "..." if the value is long.
      • print

        public void print​(@NonNull
                          java.util.Collection<T> values,
                          @NonNull
                          java.io.PrintStream out)
        Print out a table with the given values to the given stream. At least one column must have been added using addColumn(String, Function, int, int)