Klasse CoveragePercentage
java.lang.Object
io.jenkins.plugins.coverage.model.CoveragePercentage
- Alle implementierten Schnittstellen:
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:
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbooleanformatDeltaPercentage(Locale locale) Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two decimals.formatPercentage(Locale locale) Formats a percentage to plain text and rounds the value to two decimals.intdoubleCalculates the coverage percentage.intinthashCode()Returns a string representation for thisCoveragePercentagethat can be used to serialize this instance in a simple but still readable way.toString()static CoveragePercentagevalueOf(double percentage) Creates an instance ofCoveragePercentagefrom a coverage percentage value.static CoveragePercentagevalueOf(int numerator, int denominator) Creates an instance ofCoveragePercentagefrom a numerator and a denominator.static CoveragePercentageCreates a newCoveragePercentageinstance from the provided string representation.static CoveragePercentagevalueOf(org.apache.commons.lang3.math.Fraction fraction) Creates an instance ofCoveragePercentagefrom afractionwithin the range [0,1].
-
Methodendetails
-
valueOf
Creates an instance ofCoveragePercentagefrom afractionwithin the range [0,1].- Parameter:
fraction- The coverage as fraction- Gibt zurück:
- the created instance
-
valueOf
Creates an instance ofCoveragePercentagefrom a coverage percentage value.- Parameter:
percentage- The value which represents a coverage percentage- Gibt zurück:
- the created instance
-
valueOf
Creates an instance ofCoveragePercentagefrom 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
Creates a newCoveragePercentageinstance 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
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
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
-
hashCode
public int hashCode() -
serializeToString
Returns a string representation for thisCoveragePercentagethat 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
-