Class Value

    • 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 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(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 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:
        getValue(Metric, List)
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object