Class ColumnFormatter
java.lang.Object
eu.cloudnetservice.utils.base.column.ColumnFormatter
A formatter that is highly customizable to build tables from columns.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder for a column formatter. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ColumnFormatter.Builderbuilder()Constructs a new builder for a colum formatter.formatLines(@NonNull ColumnEntry... entries) Formats the given column entries into a table based on the formatter configuration.
-
Field Details
-
ENTRY_FORMAT
- See Also:
-
leftSpacer
-
rightSpacer
-
columnLeftBracket
private final char columnLeftBracket -
columnRightBracket
private final char columnRightBracket -
headerValuesSpacerChar
private final char headerValuesSpacerChar -
columnTitles
-
formattedColumnTitles
-
-
Constructor Details
-
ColumnFormatter
private ColumnFormatter(@NonNull @NonNull String leftSpacer, @NonNull @NonNull String rightSpacer, char columnLeftBracket, char columnRightBracket, char headerValuesSpacerChar, @NonNull @NonNull String[] columnTitles) Constructs a new column formatter instance.- Parameters:
leftSpacer- the spacer to put after the left bracket.rightSpacer- the right spacer to put after the column text.columnLeftBracket- the bracket to put as the first char of a column.columnRightBracket- the bracket to put as the last char of a column.headerValuesSpacerChar- the char to use in the spacer line between the header and rows.columnTitles- the display name of all column titles, in order.- Throws:
NullPointerException- if one of the given arguments is null.
-
-
Method Details
-
builder
Constructs a new builder for a colum formatter.- Returns:
- a new column formatter builder.
-
formatLines
Formats the given column entries into a table based on the formatter configuration. The returned collection is ordered and can contain duplicates (this depends on the given input and how the input is converted).- Parameters:
entries- the entries to format.- Returns:
- the given entries, formatted as a table, line by line.
- Throws:
NullPointerException- if the given entries are null.
-