public class PrintStyleBuilder extends Object
PrintStyle objects. Example:
PrintStyle printStyle = new PrintStyleBuilder()
.withHeader()
.withRowFormat("%-15s %19s")
.withDurationFormat(DurationFormat.FULL)
.withoutLegends()
.withSimpleLine('-', 36)
.build();
PrintFormat| Constructor and Description |
|---|
PrintStyleBuilder(PrintFormat printFormat)
Creates an empty PrintStyle builder.
|
PrintStyleBuilder(PrintStyle source)
Creates a new PrintStyle builder with the same attributes of an existing PrintStyle.
|
| Modifier and Type | Method and Description |
|---|---|
PrintStyle |
build()
Builds the PrintStyle.
|
static String |
generateLine(char character,
int length)
Generates a string using the specified character repeated to a given length.
|
static boolean |
isEmpty(String string)
Returns
true if the specified string is either null or empty. |
PrintStyleBuilder |
withAlternativeLine(char character,
int length)
Defines an alternative line, to be generated using the specified character repeated to
a given length.
|
PrintStyleBuilder |
withAlternativeLine(String string)
Defines an alternative line.
|
PrintStyleBuilder |
withDurationFormat(DurationFormat format)
Defines the
DurationFormat to be applied on all rows containing a time
duration. |
PrintStyleBuilder |
withHeader()
Enables the header row, to be formatted using the same general row format and preset
column names.
|
PrintStyleBuilder |
withHeader(String format)
Enables the header row and defines a specific format string in printf-style to be
applied.
|
PrintStyleBuilder |
withLegends()
Enables printing legends after time durations.
|
PrintStyleBuilder |
withoutHeader()
Explicitly disables the header row.
|
PrintStyleBuilder |
withoutLegends()
Explicitly disables legends after time durations.
|
PrintStyleBuilder |
withoutSectionSummary()
Explicitly disables the section summary row.
|
PrintStyleBuilder |
withRowFormat(String format)
Defines a format string in printf-style to be applied for all rows.
|
PrintStyleBuilder |
withSectionHeaderFormat(String format)
Defines a format string in printf-style to the applied for the section headers.
|
PrintStyleBuilder |
withSectionSummary(String format)
Enables the section summary row and defines the format string in printf-style to be
applied.
|
PrintStyleBuilder |
withSimpleLine(char character,
int length)
Defines a simple line, to be generated using the specified character repeated to a
given length.
|
PrintStyleBuilder |
withSimpleLine(String string)
Defines a simple line.
|
public PrintStyleBuilder(PrintFormat printFormat)
printFormat - the target PrintFormat, not nullNullPointerException - if the specified PrintFormat is nullpublic PrintStyleBuilder(PrintStyle source)
source - the PrintStyle whose attributes are to be copiedNullPointerException - if the specified PrintStyle is nullpublic PrintStyleBuilder withRowFormat(String format)
The position of fields must be defined according to the target PrintFormat:
SUMMARIZED
DETAILED
For example: considering the PrintFormat.SUMMARIZED and
DurationFormat.FULL, the format string "%1$s %2$s" produces
"Wall-clock time 0:00:00.049085700", while the format string
"%2$s %1$s" produces "0:00:00.049085700 Wall-clock time".
Not all fields are mandatory, so the format string "%2$s" is also valid, and
produces "0:00:00.049085700".
format - the format string to be appliedFormatter,
PrintStylepublic PrintStyleBuilder withHeader()
To specify a different format for the header row, use withHeader(String).
public PrintStyleBuilder withHeader(String format)
The number and sequence of string positions must be defined according to the target stopwatch formatter:
SUMMARIZED
DETAILED
To enable the header without specifying a custom format, use the zero-argument option
withHeader().
format - the format string to be applied for the header rowFormatter,
PrintStylepublic PrintStyleBuilder withoutHeader()
public PrintStyleBuilder withSectionHeaderFormat(String format)
format - the format string to be applied for each section header rowpublic PrintStyleBuilder withoutSectionSummary()
public PrintStyleBuilder withSectionSummary(String format)
Note: The property modified by this method is only applicable for the detailed stopwatch formatter.
format - the format string to be applied for the section summary rowpublic PrintStyleBuilder withSimpleLine(char character, int length)
character - a character to compose the stringlength - number of times to repeat the character; must be > 0public PrintStyleBuilder withSimpleLine(String string)
string - the string to be used as the simple linepublic PrintStyleBuilder withAlternativeLine(char character, int length)
character - a character to compose the stringlength - number of times to repeat the character; must be > 0public PrintStyleBuilder withAlternativeLine(String string)
string - the string to be used as the alternative linepublic PrintStyleBuilder withDurationFormat(DurationFormat format)
DurationFormat to be applied on all rows containing a time
duration.format - the DurationFormat to be appliedpublic PrintStyleBuilder withLegends()
public PrintStyleBuilder withoutLegends()
public PrintStyle build()
PrintStyle; not nullpublic static boolean isEmpty(String string)
true if the specified string is either null or empty.string - the string to be checkedpublic static String generateLine(char character, int length)
character - a character to compose the stringlength - number of times to repeat the character; must be > 0Copyright © 2021. All rights reserved.