Klasse ElementFormatter

java.lang.Object
io.jenkins.plugins.coverage.metrics.model.ElementFormatter

public final class ElementFormatter extends Object
A localized formatter for coverages, metrics, baselines, etc.
Autor:
Florian Orendi
  • Konstruktordetails

    • ElementFormatter

      public ElementFormatter()
  • Methodendetails

    • getTooltip

      public String getTooltip(edu.hm.hafner.coverage.Value value)
      Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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

      public String format(edu.hm.hafner.coverage.Value value)
      Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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

      public String format(edu.hm.hafner.coverage.Value value, Locale locale)
      Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value instances are provided by a library that is not capable of localizing these values for the user.
      Parameter:
      value - the value to format
      locale - the locale to use to render the values
      Gibt zurück:
      the formatted value as plain text
    • formatDetails

      public String formatDetails(edu.hm.hafner.coverage.Value value)
      Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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
    • formatDetails

      public String formatDetails(edu.hm.hafner.coverage.Value value, Locale locale)
      Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value instances are provided by a library that is not capable of localizing these values for the user.
      Parameter:
      value - the value to format
      locale - the locale to use to render the values
      Gibt zurück:
      the formatted value as plain text
    • formatAdditionalInformation

      public String formatAdditionalInformation(edu.hm.hafner.coverage.Value value)
      Formats additional information for a generic value using a specific rendering method. This information can be added as a tooltip. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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 show
      value - the value to format
      Gibt zurück:
      the display colors to use
    • formatValue

      public String formatValue(edu.hm.hafner.coverage.Value value)
      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

      public String formatValueWithMetric(edu.hm.hafner.coverage.Value value)
      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

      public String formatDetailedValueWithMetric(edu.hm.hafner.coverage.Value value)
      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

      public String getBackgroundColorFillPercentage(String percentage)
      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

      public String getBackgroundColorFillPercentage(edu.hm.hafner.coverage.Value value)
      Returns the fill percentage for the specified value.
      Parameter:
      value - the value to format
      Gibt zurück:
      the percentage string
    • formatPercentage

      public String formatPercentage(edu.hm.hafner.coverage.Coverage coverage, Locale locale)
      Formats a coverage as a percentage number. The shown value is multiplied by 100 and rounded by two decimals.
      Parameter:
      coverage - the coverage to format
      locale - the locale to use to render the values
      Gibt zurück:
      the formatted percentage as plain text
    • formatPercentage

      public String formatPercentage(int covered, int total, Locale locale)
      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 items
      total - the number of total items
      locale - the locale to use to render the values
      Gibt zurück:
      the formatted percentage as plain text
    • formatDelta

      public String formatDelta(org.apache.commons.lang3.math.Fraction fraction, edu.hm.hafner.coverage.Metric metric, Locale locale)
      Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two decimals.
      Parameter:
      fraction - the value of the delta
      metric - the metric of the value
      locale - the locale to use to render the values
      Gibt zurück:
      the formatted delta percentage as plain text with a leading sign
    • getDisplayName

      public String getDisplayName(edu.hm.hafner.coverage.Metric metric)
      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

      public List<String> getSortedCoverageDisplayNames()
      Gets the display names of the existing coverage metrics, sorted by the metrics ordinal.
      Gibt zurück:
      the sorted metric display names
    • 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 formatted
      locale - The locale to be used for formatting
      Gibt zurück:
      the formatted values in the origin order of the stream
    • getLabel

      public String getLabel(edu.hm.hafner.coverage.Metric metric)
      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

      public String getDisplayName(Baseline baseline)
      Returns a localized human-readable name for the specified baseline.
      Parameter:
      baseline - the baseline to get the name for
      Gibt zurück:
      the display name
    • getMetricItems

      public ListBoxModel getMetricItems()
      Returns all available metrics as a ListBoxModel.
      Gibt zurück:
      the metrics in a ListBoxModel
    • getBaselineItems

      public ListBoxModel getBaselineItems()
      Returns all available baselines as a ListBoxModel.
      Gibt zurück:
      the baselines in a ListBoxModel