Class Bar.Builder

Object
Builder
Enclosing class:
Bar

public static class Bar.Builder extends Object
Builder class to add values and build text like a bar.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Max value of the set of bars.
    private int
    Max size of the bar, units: character.
    private List<String>
    Built values of bars chart
  • Constructor Summary

    Constructors
    Constructor
    Description
    Builder(int presentationSize, int max)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Bar.Type type, int value, String title, boolean showPercentage)
    Add value, representing a bar.
    private String
    Standardised bar formatting Title [----Bar----] Percentage
    void
    Directly print the built bar contents in console.
    Retrieve all formatted content as a string.
    Retrieve all formatted bar and details strings as a list.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • presentationSize

      private int presentationSize
      Max size of the bar, units: character.
    • max

      private int max
      Max value of the set of bars.
    • values

      private List<String> values
      Built values of bars chart
  • Constructor Details

    • Builder

      public Builder(int presentationSize, int max)
  • Method Details

    • getFormat

      private String getFormat()
      Standardised bar formatting Title [----Bar----] Percentage
      Returns:
      format string.
    • add

      public Bar.Builder add(Bar.Type type, int value, String title, boolean showPercentage)
      Add value, representing a bar.
      Parameters:
      type - Render type, how it should be rendered, solid or dotted.
      value - Value of this bar. (e.g. 5 / 10)
      title - What this bar represents.
      showPercentage - Set this to true to show percentage beside bar.
      Returns:
      builder object.
    • toValues

      public List<String> toValues()
      Retrieve all formatted bar and details strings as a list.
      Returns:
      a list of strings.
    • toString

      public String toString()
      Retrieve all formatted content as a string.
      Overrides:
      toString in class Object
      Returns:
      formatted string with bars and other texts.
    • print

      public void print()
      Directly print the built bar contents in console.