Class Coverage
- java.lang.Object
-
- com.parasoft.findings.jenkins.coverage.model.Value
-
- com.parasoft.findings.jenkins.coverage.model.Coverage
-
- All Implemented Interfaces:
Serializable
public final class Coverage extends Value
Value of a code coverage metric. The code coverage is measured using the number of covered and missed items. The type of items (line, instruction, branch, mutation, file, etc.) is provided by the companion classMetric
.- Author:
- Ullrich Hafner
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Coverage.CoverageBuilder
Builder to create cachedCoverage
instances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Coverage
add(Value other)
Add the coverage from the specified instance to the coverage of this instance.org.apache.commons.lang3.math.Fraction
delta(Value other)
Computes the delta of this value with the specified value.boolean
equals(Object o)
int
getCovered()
Returns the number of covered items.Percentage
getCoveredPercentage()
Returns the percentage of covered items.int
getMissed()
Returns the number of missed items.int
getTotal()
int
hashCode()
boolean
isOutOfValidRange(double threshold)
Returns whether this coverage percentage is below the given threshold.boolean
isSet()
Coverage
max(Value other)
Merge this coverage with the specified coverage.static Coverage
nullObject(Metric metric)
Returns anull
object that indicates that no coverage has been recorded.String
serialize()
Serializes this instance into a String.String
toString()
static Coverage
valueOf(Metric metric, String stringRepresentation)
Creates a newCoverage
instance from the provided string representation.
-
-
-
Method Detail
-
valueOf
public static Coverage valueOf(Metric metric, String stringRepresentation)
Creates a newCoverage
instance from the provided string representation. The string representation is expected to contain the number of covered items and the total number of items - separated by a slash, e.g. "100/345", or "0/0". Whitespace characters will be ignored.- Parameters:
metric
- the coverage metric of this instancestringRepresentation
- string representation to convert from- Returns:
- the created coverage
- Throws:
IllegalArgumentException
- if the string is not a valid Coverage instance
-
nullObject
public static Coverage nullObject(Metric metric)
Returns anull
object that indicates that no coverage has been recorded.- Parameters:
metric
- the coverage metric- Returns:
- the
null
object
-
getCovered
public int getCovered()
Returns the number of covered items.- Returns:
- the number of covered items
-
getCoveredPercentage
public Percentage getCoveredPercentage()
Returns the percentage of covered items. If this coverage is undefined (i.e.,total
is zero) then zero will be returned.- Returns:
- the covered percentage
-
getMissed
public int getMissed()
Returns the number of missed items.- Returns:
- the number of missed items
-
add
public Coverage add(Value other)
Description copied from class:Value
Add the coverage from the specified instance to the coverage of this instance.
-
delta
public org.apache.commons.lang3.math.Fraction delta(Value other)
Description copied from class:Value
Computes the delta of this value with the specified value.
-
max
public Coverage max(Value other)
Description copied from class:Value
Merge this coverage with the specified coverage.
-
isOutOfValidRange
public boolean isOutOfValidRange(double threshold)
Returns whether this coverage percentage is below the given threshold. The threshold must be a percentage in the range of [0, 100].- Specified by:
isOutOfValidRange
in classValue
- Parameters:
threshold
- the threshold in the range of [0, 100]- Returns:
true
, if this value is below the specified threshold
-
getTotal
public int getTotal()
-
isSet
public boolean isSet()
-
-