Class Value
- java.lang.Object
-
- com.parasoft.findings.jenkins.coverage.model.Value
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Coverage
,FractionValue
,IntegerValue
public abstract class Value extends Object implements Serializable
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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Value
add(Value other)
Add the coverage from the specified instance to the coverage of this instance.abstract org.apache.commons.lang3.math.Fraction
delta(Value other)
Computes the delta of this value with the specified value.boolean
equals(Object o)
static Optional<Value>
findValue(Metric metric, List<Value> values)
Searches for a value with the specified metric in the specified list of values.Metric
getMetric()
static Value
getValue(Metric metric, List<Value> values)
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
max(Value other)
Merge this coverage with the specified coverage.abstract String
serialize()
Serializes this instance into a String.static Value
valueOf(String stringRepresentation)
Creates a newValue
instance from the provided string representation.
-
-
-
Constructor Detail
-
Value
protected Value(Metric metric)
Creates a new leaf with the given coverage for the specified metric.- Parameters:
metric
- the coverage metric
-
-
Method Detail
-
getValue
public static Value getValue(Metric metric, List<Value> values)
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(Metric, List)
-
findValue
public static Optional<Value> findValue(Metric metric, List<Value> values)
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:
getValue(Metric, List)
-
valueOf
public static Value valueOf(String stringRepresentation)
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
public final Metric getMetric()
-
add
@CheckReturnValue public abstract Value add(Value other)
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
@CheckReturnValue public abstract org.apache.commons.lang3.math.Fraction delta(Value other)
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
@CheckReturnValue public abstract Value max(Value other)
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
public abstract String serialize()
Serializes this instance into a String.- Returns:
- a String serialization of this value
-
hasSameMetric
protected boolean hasSameMetric(Value other)
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
-
-