001/*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020
021package org.sonar.api.measures;
022
023import java.util.List;
024
025/**
026 * @since 3.0
027 * @deprecated since 5.2. Aggregation of measures is provided by {@link org.sonar.api.ce.measure.MeasureComputer}. {@link org.sonar.api.batch.Decorator}
028 * and {@link Formula} are no more supported.
029 */
030@Deprecated
031public class AverageFormula implements Formula {
032
033  /**
034   * Creates a new {@link AverageFormula} class.
035   *
036   * @param main The metric on which average should be calculated (ex.: "complexity")
037   * @param by   The metric used to divide the main metric to compute average (ex.: "file" for "complexity by file")
038   */
039  public static AverageFormula create(Metric main, Metric by) {
040    return new AverageFormula();
041  }
042
043  /**
044   * Set a fallback metric if no measures found for the main metric.
045   *
046   * @param fallbackMetric The fallback metric
047   * @since 3.6
048   */
049  public AverageFormula setFallbackForMainMetric(Metric fallbackMetric) {
050    throw fail();
051  }
052
053  /**
054   * {@inheritDoc}
055   */
056  @Override
057  public List<Metric> dependsUponMetrics() {
058    throw fail();
059  }
060
061  /**
062   * {@inheritDoc}
063   */
064  @Override
065  public Measure calculate(FormulaData data, FormulaContext context) {
066    throw fail();
067  }
068
069  private static RuntimeException fail() {
070    throw new UnsupportedOperationException("Unsupported since version 5.2. Decorators and formulas are not used anymore for aggregation measures. " +
071      "Please use org.sonar.api.ce.measure.MeasureComputer.");
072  }
073}