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 */
020package org.sonar.api.batch;
021
022import java.util.Collection;
023import java.util.List;
024import org.sonar.api.design.Dependency;
025import org.sonar.api.measures.Measure;
026import org.sonar.api.measures.MeasuresFilter;
027import org.sonar.api.measures.Metric;
028import org.sonar.api.resources.Project;
029import org.sonar.api.resources.Resource;
030
031/**
032 * @since 1.10
033 */
034public interface DecoratorContext {
035
036  /**
037   * @return the project in which the decorator is
038   */
039  Project getProject();
040
041  /**
042   * @return the resource that is currently decorated
043   */
044  Resource getResource();
045
046  /**
047   * Child contexts are read only
048   */
049  List<DecoratorContext> getChildren();
050
051  // MEASURES
052
053  /**
054   * Find a measure for the resource
055   */
056  Measure getMeasure(Metric metric);
057
058  /**
059   * Never return null.
060   */
061  <M> M getMeasures(MeasuresFilter<M> filter);
062
063  /**
064   * Never return null.
065   */
066  Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
067
068  /**
069   * @return the resource children measures for the given metric
070   */
071  Collection<Measure> getChildrenMeasures(Metric metric);
072
073  /**
074   * Add a new measure on the current resource. It can not be executed from children contexts.
075   * 
076   * @return the same context
077   */
078  DecoratorContext saveMeasure(Measure measure);
079
080  /**
081   * Add a new measure on the current resource. It can not be executed from children contexts.
082   * 
083   * @return the current object
084   */
085  DecoratorContext saveMeasure(Metric metric, Double value);
086
087  // DEPENDENCIES
088  /**
089   * @deprecated since 5.2 No more design features. No-op.
090   */
091  @Deprecated
092  Dependency saveDependency(Dependency dependency);
093
094}