Class Value
java.lang.Object
com.parasoft.findings.jenkins.coverage.model.Value
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Coverage
,FractionValue
,IntegerValue
A leaf in the tree. A leaf is a non-divisible coverage metric like line, instruction or branch coverage or mutation
or complexity.
- Author:
- Ullrich Hafner
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Value
Add the coverage from the specified instance to the coverage of this instance.abstract org.apache.commons.lang3.math.Fraction
Computes the delta of this value with the specified value.boolean
Searches for a value with the specified metric in the specified list of values.final Metric
static Value
Searches for a value with the specified metric in the specified list of values.int
hashCode()
protected boolean
hasSameMetric
(Value other) Returns whether this value has the same metric as the specified value.abstract boolean
isOutOfValidRange
(double threshold) Returns whether this value if within the specified threshold (given as double value).abstract Value
Merge this coverage with the specified coverage.abstract String
Serializes this instance into a String.static Value
Creates a newValue
instance from the provided string representation.
-
Constructor Details
-
Value
Creates a new leaf with the given coverage for the specified metric.- Parameters:
metric
- the coverage metric
-
-
Method Details
-
getValue
Searches for a value with the specified metric in the specified list of values.- Parameters:
metric
- the metric to search forvalues
- the values to search in- Returns:
- the value with the specified metric
- Throws:
NoSuchElementException
- if the value is not found- See Also:
-
findValue
Searches for a value with the specified metric in the specified list of values.- Parameters:
metric
- the metric to search forvalues
- the values to search in- Returns:
- the value with the specified metric, or an empty optional if the value is not found
- See Also:
-
valueOf
Creates a newValue
instance from the provided string representation. The string representation is expected start with the metric, written in all caps characters and followed by a colon. Then theValue
specific serialization is following. Whitespace characters will be ignored.Examples: LINE: 10/100, BRANCH: 0/5, COMPLEXITY: 160
- Parameters:
stringRepresentation
- string representation to convert from- Returns:
- the created value
- Throws:
IllegalArgumentException
- if the string is not a valid cov instance
-
getMetric
-
add
Add the coverage from the specified instance to the coverage of this instance.- Parameters:
other
- the additional coverage details- Returns:
- the sum of this and the additional coverage
-
delta
Computes the delta of this value with the specified value.- Parameters:
other
- the value to compare with- Returns:
- the delta of this and the additional value
-
max
Merge this coverage with the specified coverage.- Parameters:
other
- the other coverage- Returns:
- the merged coverage
- Throws:
IllegalArgumentException
- if the totals
-
isOutOfValidRange
public abstract boolean isOutOfValidRange(double threshold) Returns whether this value if within the specified threshold (given as double value). For metrics of typeMetric.MetricTendency.LARGER_IS_BETTER
(like coverage percentage) this value will be checked with greater or equal than the threshold. For metrics of typeMetric.MetricTendency.SMALLER_IS_BETTER
(like complexity) this value will be checked with less or equal than.- Parameters:
threshold
- the threshold to check against- Returns:
true
if this value is within the specified threshold,false
otherwise
-
serialize
Serializes this instance into a String.- Returns:
- a String serialization of this value
-
hasSameMetric
Returns whether this value has the same metric as the specified value.- Parameters:
other
- the other value to compare with- Returns:
true
if this value has the same metric as the specified value,false
otherwise
-
equals
-
hashCode
public int hashCode()
-