Klasse ElementFormatter
java.lang.Object
io.jenkins.plugins.coverage.metrics.model.ElementFormatter
A localized formatter for coverages, metrics, baselines, etc.
- Autor:
- Florian Orendi
-
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungformat
(edu.hm.hafner.coverage.Value value) Formats a generic value using a specific rendering method.Formats a generic value using a specific rendering method.formatAdditionalInformation
(edu.hm.hafner.coverage.Value value) Formats additional information for a generic value using a specific rendering method.formatDelta
(edu.hm.hafner.coverage.Metric metric, org.apache.commons.lang3.math.Fraction fraction, Locale locale) Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two decimals.formatDetailedValueWithMetric
(edu.hm.hafner.coverage.Value value) Returns a formatted and localized String representation of the specified value prefixed with the metric name.formatDetails
(edu.hm.hafner.coverage.Value value) Formats a generic value using a specific rendering method.formatPercentage
(int covered, int total, Locale locale) Formats a coverage given by covered and total elements as a percentage number.formatPercentage
(edu.hm.hafner.coverage.Coverage coverage, Locale locale) Formats a coverage as a percentage number.formatValue
(edu.hm.hafner.coverage.Value value) Returns a formatted and localized String representation of the specified value (without metric).formatValueWithMetric
(edu.hm.hafner.coverage.Value value) Returns a formatted and localized String representation of the specified value prefixed with the metric name.getBackgroundColorFillPercentage
(edu.hm.hafner.coverage.Value value) Returns the fill percentage for the specified value.getBackgroundColorFillPercentage
(String percentage) Transforms percentages with a ',' decimal separator to a representation using a '.' in order to use the percentage for styling HTML tags.Returns all available baselines as aListBoxModel
.getDisplayColors
(Baseline baseline, edu.hm.hafner.coverage.Value value) Provides the colors to render a given coverage percentage.getDisplayName
(edu.hm.hafner.coverage.Metric metric) Returns a localized human-readable name for the specified metric.getDisplayName
(Baseline baseline) Returns a localized human-readable name for the specified baseline.getFormattedValues
(Stream<? extends edu.hm.hafner.coverage.Value> values, Locale locale) Formats a stream of values to their display representation by using the given locale.getLabel
(edu.hm.hafner.coverage.Metric metric) Returns a localized human-readable label for the specified metric.Returns all available metrics as aListBoxModel
.Gets the display names of the existingcoverage metrics
, sorted by the metrics ordinal.getTooltip
(edu.hm.hafner.coverage.Value value) Formats a generic value using a specific rendering method.boolean
showColors
(edu.hm.hafner.coverage.Value value) Returns whether the value should be rendered by using a color badge.
-
Konstruktordetails
-
ElementFormatter
public ElementFormatter()
-
-
Methodendetails
-
getTooltip
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameter:
value
- the value to format- Gibt zurück:
- the formatted value as plain text
-
format
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameter:
value
- the value to format- Gibt zurück:
- the formatted value as plain text
-
format
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameter:
value
- the value to formatlocale
- the locale to use to render the values- Gibt zurück:
- the formatted value as plain text
-
formatDetails
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameter:
value
- the value to format- Gibt zurück:
- the formatted value as plain text
-
formatAdditionalInformation
Formats additional information for a generic value using a specific rendering method. This information can be added as a tooltip. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameter:
value
- the value to format- Gibt zurück:
- the formatted value as plain text
-
showColors
public boolean showColors(edu.hm.hafner.coverage.Value value) Returns whether the value should be rendered by using a color badge.- Parameter:
value
- the value to render- Gibt zurück:
true
if the value should be rendered by using a color badge,false
otherwise
-
getDisplayColors
public ColorProvider.DisplayColors getDisplayColors(Baseline baseline, edu.hm.hafner.coverage.Value value) Provides the colors to render a given coverage percentage.- Parameter:
baseline
- the baseline to showvalue
- the value to format- Gibt zurück:
- the display colors to use
-
formatValue
Returns a formatted and localized String representation of the specified value (without metric).- Parameter:
value
- the value to format- Gibt zurück:
- the value formatted as a string
-
formatValueWithMetric
Returns a formatted and localized String representation of the specified value prefixed with the metric name.- Parameter:
value
- the value to format- Gibt zurück:
- the value formatted as a string
-
formatDetailedValueWithMetric
Returns a formatted and localized String representation of the specified value prefixed with the metric name. The value will be printed with all details (number of covered and missed items).- Parameter:
value
- the value to format- Gibt zurück:
- the value formatted as a string
-
getBackgroundColorFillPercentage
Transforms percentages with a ',' decimal separator to a representation using a '.' in order to use the percentage for styling HTML tags.- Parameter:
percentage
- The text representation of a percentage- Gibt zurück:
- the formatted percentage string
-
getBackgroundColorFillPercentage
Returns the fill percentage for the specified value.- Parameter:
value
- the value to format- Gibt zurück:
- the percentage string
-
formatPercentage
Formats a coverage as a percentage number. The shown value is multiplied by 100 and rounded by two decimals.- Parameter:
coverage
- the coverage to formatlocale
- the locale to use to render the values- Gibt zurück:
- the formatted percentage as plain text
-
formatPercentage
Formats a coverage given by covered and total elements as a percentage number. The shown value is multiplied by 100 and * rounded by two decimals.- Parameter:
covered
- the number of covered itemstotal
- the number of total itemslocale
- the locale to use to render the values- Gibt zurück:
- the formatted percentage as plain text
-
formatDelta
public String formatDelta(edu.hm.hafner.coverage.Metric metric, org.apache.commons.lang3.math.Fraction fraction, Locale locale) Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two decimals.- Parameter:
metric
- the metric of the valuefraction
- the value of the deltalocale
- the locale to use to render the values- Gibt zurück:
- the formatted delta percentage as plain text with a leading sign
-
getDisplayName
Returns a localized human-readable name for the specified metric.- Parameter:
metric
- the metric to get the name for- Gibt zurück:
- the display name
-
getSortedCoverageDisplayNames
-
getFormattedValues
public List<String> getFormattedValues(Stream<? extends edu.hm.hafner.coverage.Value> values, Locale locale) Formats a stream of values to their display representation by using the given locale.- Parameter:
values
- The values to be formattedlocale
- The locale to be used for formatting- Gibt zurück:
- the formatted values in the origin order of the stream
-
getLabel
Returns a localized human-readable label for the specified metric.- Parameter:
metric
- the metric to get the label for- Gibt zurück:
- the display name
-
getDisplayName
-
getMetricItems
Returns all available metrics as aListBoxModel
.- Gibt zurück:
- the metrics in a
ListBoxModel
-
getBaselineItems
Returns all available baselines as aListBoxModel
.- Gibt zurück:
- the baselines in a
ListBoxModel
-