Class ColumnFormatter.Builder

java.lang.Object
eu.cloudnetservice.utils.base.column.ColumnFormatter.Builder
Enclosing class:
ColumnFormatter

public static final class ColumnFormatter.Builder extends Object
A builder for a column formatter. By default the builder uses
  1. | as the left bracket
  2. a space as the right bracket
  3. a space as the left spacer
  4. an empty string as the right spacer
  5. for the header spacing.
Since:
4.0
  • Field Details

    • leftSpacer

      private String leftSpacer
    • rightSpacer

      private String rightSpacer
    • columnLeftBracket

      private char columnLeftBracket
    • columnRightBracket

      private char columnRightBracket
    • headerValuesSpacerChar

      private char headerValuesSpacerChar
    • columnTitles

      private String[] columnTitles
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • leftSpacer

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder leftSpacer(@NonNull @NonNull String leftSpacer)
      Sets the left spacer to apply to the column. The left spacer is printed after the left bracket. This value defaults to a space.
      Parameters:
      leftSpacer - the left spacer to use.
      Returns:
      the same builder instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given left spacer is null.
    • rightSpacer

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder rightSpacer(@NonNull @NonNull String rightSpacer)
      Sets the right spacer to apply to the column. The right spacer is printed after the value of entry and before the right bracket. This value defaults to an empty string.
      Parameters:
      rightSpacer - the right spacer to use.
      Returns:
      the same builder instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given right spacer is null.
    • columnLeftBracket

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder columnLeftBracket(char columnLeftBracket)
      Sets the left bracket to apply to the column. The left bracket is the first char printed in each line. This value defaults to |.
      Parameters:
      columnLeftBracket - the left bracket to use.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • columnRightBracket

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder columnRightBracket(char columnRightBracket)
      Sets the right bracket to apply to the column. The right bracket is the last char printed in each line. This value defaults to a space.
      Parameters:
      columnRightBracket - the right bracket to use.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • headerValuesSpacerChar

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder headerValuesSpacerChar(char headerValuesSpacerChar)
      Sets the spacer character to apply between the header of a table and the table values. This value defaults to .
      Parameters:
      headerValuesSpacerChar - the spacer char to use.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • columnTitles

      @Contract(value="_ -> this", pure=true) @NonNull public @NonNull ColumnFormatter.Builder columnTitles(@NonNull @NonNull List<String> columnTitles)
      Sets the column titles to use for the table. This method copies the given list of titles into this builder, meaning that changes to the given list are not reflected into this builder.
      Parameters:
      columnTitles - the colum titles.
      Returns:
      the same builder instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given column titles list is null.
    • columnTitles

      @NonNull public @NonNull ColumnFormatter.Builder columnTitles(@NonNull @NonNull String... columnTitles)
      Sets the column titles to use for the table. This method copies the given array of titles into this builder, meaning that changes to the given array are not reflected into this builder.
      Parameters:
      columnTitles - the colum titles.
      Returns:
      the same builder instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given column titles array is null.
    • build

      @Contract(value="-> new", pure=true) @NonNull public @NonNull ColumnFormatter build()
      Constructs a new column formatter instance from the values supplied to this builder.
      Returns:
      a new column formatter instance.
      Throws:
      IllegalArgumentException - if no column titles were given to this builder.