001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program 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 * This program 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 * @deprecated since 5.6 as {@link Decorator} is deprecated
034 */
035@Deprecated
036public interface DecoratorContext {
037
038  /**
039   * @return the project in which the decorator is
040   */
041  Project getProject();
042
043  /**
044   * @return the resource that is currently decorated
045   */
046  Resource getResource();
047
048  /**
049   * Child contexts are read only
050   */
051  List<DecoratorContext> getChildren();
052
053  // MEASURES
054
055  /**
056   * Find a measure for the resource
057   */
058  Measure getMeasure(Metric metric);
059
060  /**
061   * Never return null.
062   */
063  <M> M getMeasures(MeasuresFilter<M> filter);
064
065  /**
066   * Never return null.
067   */
068  Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
069
070  /**
071   * @return the resource children measures for the given metric
072   */
073  Collection<Measure> getChildrenMeasures(Metric metric);
074
075  /**
076   * Add a new measure on the current resource. It can not be executed from children contexts.
077   * 
078   * @return the same context
079   */
080  DecoratorContext saveMeasure(Measure measure);
081
082  /**
083   * Add a new measure on the current resource. It can not be executed from children contexts.
084   * 
085   * @return the current object
086   */
087  DecoratorContext saveMeasure(Metric metric, Double value);
088
089  // DEPENDENCIES
090  /**
091   * @deprecated since 5.2 No more design features. No-op.
092   */
093  @Deprecated
094  Dependency saveDependency(Dependency dependency);
095
096}