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 class Metric.
Author:
Ullrich Hafner
See Also:
  • Method Details

    • valueOf

      public static Coverage valueOf(Metric metric, String stringRepresentation)
      Creates a new Coverage 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 instance
      stringRepresentation - 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 a null 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.
      Specified by:
      add in class Value
      Parameters:
      other - the additional coverage details
      Returns:
      the sum of this and the additional coverage
    • 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.
      Specified by:
      delta in class Value
      Parameters:
      other - the value to compare with
      Returns:
      the delta of this and the additional value
    • max

      public Coverage max(Value other)
      Description copied from class: Value
      Merge this coverage with the specified coverage.
      Specified by:
      max in class Value
      Parameters:
      other - the other coverage
      Returns:
      the merged 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 class Value
      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()
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serialize

      public String serialize()
      Description copied from class: Value
      Serializes this instance into a String.
      Specified by:
      serialize in class Value
      Returns:
      a String serialization of this value