Class TableDefinition

java.lang.Object
org.variantsync.diffdetective.tablegen.TableDefinition
Direct Known Subclasses:
ShortTable, Table1, VariabilityShare

public abstract class TableDefinition extends Object
Definitions for the style of a table. The style of a table includes the format of numbers and the definition of all columns including their name in the header as well as a way to obtain their content..
  • Field Details

    • intFormat

      protected NumberFormat intFormat
      Format used to pretty print integers.
    • doubleFormat

      protected NumberFormat doubleFormat
      Format used to pretty print doubles.
    • columnDefinitions

      protected final List<ColumnDefinition> columnDefinitions
      Definition of all columns in the table.
  • Constructor Details

    • TableDefinition

      protected TableDefinition(List<ColumnDefinition> columnDefinitions)
      Creates a table definition with columnDefinitions as columns. Numbers are use the US locale and doubles round to one digit after the decimal point a using RoundingMode.HALF_UP.
  • Method Details

    • makeReadable

      public String makeReadable(Number number)
      Pretty prints a number as either a int or double. The selected type depends on presence of a fractional part in number.
      See Also:
    • makeReadable

      public String makeReadable(int number)
      Pretty prints number as int.
      See Also:
    • makeReadable

      public String makeReadable(double number)
      Pretty prints number as double, treating infinity and NaN as absent.
      See Also:
    • makeReadable

      public String makeReadable(long number)
      Pretty prints number as long, treating -1 as absent.
      See Also:
    • makeReadable

      public String makeReadable(String number)
      Pretty prints number as double, treating infinity and NaN as absent.
      See Also:
    • sortAndFilter

      public abstract List<? extends Row> sortAndFilter(List<ContentRow> rows, ContentRow ultimateResult)
      Returns a list of all rows that should appear in the table. The list of rows is final after this step, only the header is prepended.
      Parameters:
      rows - the data to be sorted and filtered
      ultimateResult - a row containing accumulated results of rows
    • columnDefinitions

      public List<ColumnDefinition> columnDefinitions()
      Returns the list of columns in the table.
    • col

      public static ColumnDefinition col(String header, Alignment alignment, Function<ContentRow,Object> getCell)
      Constructs a new column definition.