Class DisplayMenu.Builder

Object
Builder
Enclosing class:
DisplayMenu

public static class DisplayMenu.Builder extends Object
Use this class to build a menu.
  • Field Details

    • title

      private String title
      Title of the rectangle box, centered on top. Optional.
    • contents

      private List<List<String>> contents
      Sections of rows of content
    • current

      private List<String> current
      Incomplete section of content of currrent.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • setTitle

      public DisplayMenu.Builder setTitle(String title)
      Set the title of this menu.
      Parameters:
      title - The title to be shown in menu.
      Returns:
      this builder object.
    • addContents

      public DisplayMenu.Builder addContents(List<String> contents)
      Add an entire section of this menu or table. If there exists an incomplete section, calling this will finalise that section.
      Parameters:
      contents - Row of contents.
      Returns:
      this builder object.
    • addContent

      public DisplayMenu.Builder addContent(String content)
      Add a row in the current section of this menu or table.
      Parameters:
      content - A new row of content.
      Returns:
      this builder object.
    • addCenteredContent

      public DisplayMenu.Builder addCenteredContent(String content, int width)
      Add a row where contents in this row is centered, as long as width provided fits the menu/table well.
      Parameters:
      content - A new row of content.
      width - width of this row, unit: characters.
      Returns:
      this builder object.
    • addDivider

      public DisplayMenu.Builder addDivider()
      Finalise the current section by adding the divider.
      Returns:
      this builder object.
    • build

      public DisplayMenu build()
      Finalise and build menu or table.
      Returns:
      display menu object, which can export to String or display menu or table in console.