3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.ce.task.projectanalysis.measure;
22 import com.google.common.collect.SetMultimap;
23 import java.util.Optional;
25 import org.sonar.ce.task.projectanalysis.component.Component;
26 import org.sonar.ce.task.projectanalysis.metric.Metric;
27 import org.sonar.ce.task.projectanalysis.metric.MetricImpl;
29 public interface MeasureRepository {
32 * Retrieves the base measure (ie. the one currently existing in DB) for the specified {@link Component} for
33 * the specified {@link MetricImpl} if it exists.
35 * This method searches for Measure which are specific to the Component and not associated to a rule or a
39 * @throws NullPointerException if either argument is {@code null}
41 Optional<Measure> getBaseMeasure(Component component, Metric metric);
44 * Retrieves the measure created during the current analysis for the specified {@link Component} for the specified
45 * {@link Metric} if it exists (ie. one created by the Compute Engine or the Batch) and which is <strong>not</strong>
46 * associated to a rule, a characteristic, or a developer.
48 Optional<Measure> getRawMeasure(Component component, Metric metric);
51 * Returns the {@link Measure}s for the specified {@link Component} and the specified {@link Metric}.
53 * Their will be one measure not associated to rules, characteristics or developers, the other ones will be associated to rules or to characteristics
54 * (see {@link Measure#equals(Object)}.
57 Set<Measure> getRawMeasures(Component component, Metric metric);
60 * Returns the {@link Measure}s for the specified {@link Component} mapped by their metric key.
62 * Their can be multiple measures for the same Metric but only one which has no rule nor characteristic, one with a
63 * specific ruleId and one with specific characteristicId (see {@link Measure#equals(Object)}.
66 SetMultimap<String, Measure> getRawMeasures(Component component);
69 * Adds the specified measure for the specified Component and Metric. There can be no more than one measure for a
70 * specific combination of Component, Metric and association to a specific rule or characteristic.
72 * @throws NullPointerException if any of the arguments is null
73 * @throws UnsupportedOperationException when trying to add a measure when one already exists for the specified Component/Metric paar
75 void add(Component component, Metric metric, Measure measure);
78 * Updates the specified measure for the specified Component and Metric. There can be no more than one measure for a
79 * specific combination of Component, Metric and association to a specific rule or characteristic.
81 * @throws NullPointerException if any of the arguments is null
82 * @throws UnsupportedOperationException when trying to update a non existing measure
84 void update(Component component, Metric metric, Measure measure);