Class FractionValue

java.lang.Object
com.parasoft.findings.jenkins.coverage.model.Value
com.parasoft.findings.jenkins.coverage.model.FractionValue
All Implemented Interfaces:
Serializable

public final class FractionValue extends Value
Represents the value of a rational number based metric. Internally the rational number is stored using a Fraction instance.
Author:
Ullrich Hafner
See Also:
  • Constructor Details

    • FractionValue

      public FractionValue(Metric metric, org.apache.commons.lang3.math.Fraction fraction)
      Creates a new FractionValue with the specified value for the given metric.
      Parameters:
      metric - the coverage metric
      fraction - the value to store
    • FractionValue

      public FractionValue(Metric metric, int numerator, int denominator)
      Creates a new FractionValue from the specified counters for the given metric.
      Parameters:
      metric - the coverage metric
      numerator - the numerator of the rational number
      denominator - the denominator of the rational number
  • Method Details

    • getFraction

      public org.apache.commons.lang3.math.Fraction getFraction()
    • add

      public Value 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 Value 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 fraction is out of the valid range. For values that have a metric that is getting better when values are increasing (e.g., coverage), the method will return true if the fraction value is smaller than the threshold. For values that have a metric that is getting better when values are decreasing (e.g., complexity), the method will return true if the fraction value is larger than the threshold.
      Specified by:
      isOutOfValidRange in class Value
      Parameters:
      threshold - the threshold to compare with
      Returns:
      true, if this value is larger or smaller than specified threshold (see Metric.MetricTendency)
    • 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
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Value