org.sonar.api.measures
Class AverageFormula

java.lang.Object
  extended by org.sonar.api.measures.AverageFormula
All Implemented Interfaces:
Formula
Direct Known Subclasses:
AverageComplexityFormula

public class AverageFormula
extends Object
implements Formula

Formula used to compute an average for a given metric A, which is the result of the sum of measures of this metric (A) divided by another metric (B).

For example: to compute the metric "complexity by file", the main metric (A) is "complexity" and the other metric (B) is "file".

Since:
3.0

Method Summary
 Measure calculate(FormulaData data, FormulaContext context)
          
static AverageFormula create(Metric main, Metric by)
          Creates a new AverageFormula class.
 List<Metric> dependsUponMetrics()
          
 AverageFormula setFallbackForMainMetric(Metric fallbackMetric)
          Set a fallback metric if no measures found for the main metric.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static AverageFormula create(Metric main,
                                    Metric by)
Creates a new AverageFormula class.

Parameters:
main - The metric on which average should be calculated (ex.: "complexity")
by - The metric used to divide the main metric to compute average (ex.: "file" for "complexity by file")

setFallbackForMainMetric

public AverageFormula setFallbackForMainMetric(Metric fallbackMetric)
Set a fallback metric if no measures found for the main metric.

Parameters:
fallbackMetric - The fallback metric
Since:
3.6

dependsUponMetrics

public List<Metric> dependsUponMetrics()

Specified by:
dependsUponMetrics in interface Formula

calculate

public Measure calculate(FormulaData data,
                         FormulaContext context)

Specified by:
calculate in interface Formula


Copyright © 2009-2013 SonarSource. All Rights Reserved.