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 |
resetCustomCounterNames()
Resets any preset custom counter names in the target
PrintStyle. |
PrintStyleBuilder |
withAllTypes()
Removes any type exclusion configuration at the target print style.
|
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 |
withCustomCounterName(Counter.Type type,
String name)
Defines a custom counter name for a specific counter type.
|
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 |
withoutSectionTrailer()
Explicitly disables the section trailer row.
|
PrintStyleBuilder |
withoutTrailer()
Explicitly disables the trailer row.
|
PrintStyleBuilder |
withoutTypes(Counter.Type... excludedTypes)
Removes the specified type(s) from the output, if present in the stopwatch.
|
PrintStyleBuilder |
withRowFormat(String format)
Defines a format string in printf-style to be applied for all rows.
|
PrintStyleBuilder |
withSectionHeader(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 |
withSectionTrailer(String format)
Enables the section trailer 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.
|
PrintStyleBuilder |
withTrailer(String format)
Enables the trailer row and defines a specific format string in printf-style to be
applied.
|
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 withTrailer(String format)
The number and sequence of string positions must be defined according to the target stopwatch formatter:
SUMMARIZED
DETAILED
format - the format string to be applied for the trailer rowFormatter,
PrintStylepublic PrintStyleBuilder withoutTrailer()
public PrintStyleBuilder withSectionHeader(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 withoutSectionTrailer()
public PrintStyleBuilder withSectionTrailer(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 trailer 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 PrintStyleBuilder withoutTypes(Counter.Type... excludedTypes)
excludedTypes - one or more types to excludepublic PrintStyleBuilder withAllTypes()
public PrintStyleBuilder withCustomCounterName(Counter.Type type, String name)
Subsequent calls to this method will add new pairs of type and custom name to the target map.
If a counter type is not specified, the default counter name (determined by
Counter.Type.toString()) will be applied in the output generated by the target
PrintStyle.
type - the counter type to be specifiedname - the custom name to be associated with the counter typepublic PrintStyleBuilder resetCustomCounterNames()
PrintStyle.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 © 2023. All rights reserved.