Klasse CoveragePercentage

java.lang.Object
io.jenkins.plugins.coverage.model.CoveragePercentage
Alle implementierten Schnittstellen:
Serializable

public final class CoveragePercentage extends Object implements Serializable
Represents a coverage percentage value which can be used in order to show and serialize coverage values. The class can also be used for transforming a coverage fraction into its percentage representation. The percentage is represented by a numerator and a denominator.
Autor:
Florian Orendi
Siehe auch:
  • Methodendetails

    • valueOf

      public static CoveragePercentage valueOf(org.apache.commons.lang3.math.Fraction fraction)
      Creates an instance of CoveragePercentage from a fraction within the range [0,1].
      Parameter:
      fraction - The coverage as fraction
      Gibt zurück:
      the created instance
    • valueOf

      public static CoveragePercentage valueOf(double percentage)
      Creates an instance of CoveragePercentage from a coverage percentage value.
      Parameter:
      percentage - The value which represents a coverage percentage
      Gibt zurück:
      the created instance
    • valueOf

      public static CoveragePercentage valueOf(int numerator, int denominator)
      Creates an instance of CoveragePercentage from a numerator and a denominator.
      Parameter:
      numerator - The numerator of the fraction which represents the percentage within the range [0,100]
      denominator - The denominator of the fraction which represents the percentage within the range [0,100] (must not be zero)
      Gibt zurück:
      the created instance
      Löst aus:
      IllegalArgumentException - if the denominator is zero
    • valueOf

      public static CoveragePercentage valueOf(String stringRepresentation)
      Creates a new CoveragePercentage instance from the provided string representation. The string representation is expected to contain the numerator and the denominator - separated by a slash, e.g. "500/345", or "100/1". Whitespace characters will be ignored.
      Parameter:
      stringRepresentation - string representation to convert from
      Gibt zurück:
      the created CoveragePercentage
      Löst aus:
      IllegalArgumentException - if the string is not a valid CoveragePercentage instance
    • getDoubleValue

      public double getDoubleValue()
      Calculates the coverage percentage.
      Gibt zurück:
      the coverage percentage
    • formatPercentage

      public String formatPercentage(Locale locale)
      Formats a percentage to plain text and rounds the value to two decimals.
      Parameter:
      locale - The used locale
      Gibt zurück:
      the formatted percentage as plain text
    • formatDeltaPercentage

      public String formatDeltaPercentage(Locale locale)
      Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two decimals.
      Parameter:
      locale - The used locale
      Gibt zurück:
      the formatted delta percentage as plain text with a leading sign
    • getNumerator

      public int getNumerator()
    • getDenominator

      public int getDenominator()
    • equals

      public boolean equals(Object o)
      Setzt außer Kraft:
      equals in Klasse Object
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object
    • serializeToString

      public String serializeToString()
      Returns a string representation for this CoveragePercentage that can be used to serialize this instance in a simple but still readable way. The serialization contains the numerator and the denominator - separated by a slash, e.g. "100/345", or "0/1".
      Gibt zurück:
      a string representation for this CoveragePercentage
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object