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:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Value(Metric metric)
    Creates a new leaf with the given coverage for the specified metric.
  • Method Summary

    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
     
    static Optional<Value>
    findValue(Metric metric, List<Value> values)
    Searches for a value with the specified metric in the specified list of values.
    final Metric
     
    static Value
    getValue(Metric metric, List<Value> values)
    Searches for a value with the specified metric in the specified list of values.
    int
     
    protected boolean
    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
    Serializes this instance into a String.
    static Value
    valueOf(String stringRepresentation)
    Creates a new Value instance from the provided string representation.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Value

      protected Value(Metric metric)
      Creates a new leaf with the given coverage for the specified metric.
      Parameters:
      metric - the coverage metric
  • Method Details

    • 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 for
      values - the values to search in
      Returns:
      the value with the specified metric
      Throws:
      NoSuchElementException - if the value is not found
      See Also:
    • 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 for
      values - 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

      public static Value valueOf(String stringRepresentation)
      Creates a new Value 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 the Value 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 type Metric.MetricTendency.LARGER_IS_BETTER (like coverage percentage) this value will be checked with greater or equal than the threshold. For metrics of type Metric.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
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object