3 * Copyright (C) 2009-2017 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.server.computation.task.projectanalysis.measure;
22 import java.util.Collection;
25 import org.sonar.server.computation.task.projectanalysis.component.Component;
26 import org.sonar.server.computation.task.projectanalysis.metric.Metric;
27 import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
29 import com.google.common.base.Optional;
30 import com.google.common.collect.SetMultimap;
32 public interface MeasureRepository {
35 * Retrieves the base measure (ie. the one currently existing in DB) for the specified {@link Component} for
36 * the specified {@link MetricImpl} if it exists.
38 * This method searches for Measure which are specific to the Component and not associated to a rule or a
42 * @throws NullPointerException if either argument is {@code null}
44 Optional<Measure> getBaseMeasure(Component component, Metric metric);
46 int loadAsRawMeasures(Collection<Component> components, Collection<Metric> metrics);
49 * Retrieves the measure created during the current analysis for the specified {@link Component} for the specified
50 * {@link Metric} if it exists (ie. one created by the Compute Engine or the Batch) and which is <strong>not</strong>
51 * associated to a rule, a characteristic, or a developer.
53 Optional<Measure> getRawMeasure(Component component, Metric metric);
56 * Returns the {@link Measure}s for the specified {@link Component} and the specified {@link Metric}.
58 * Their will be one measure not associated to rules, characteristics or developers, the other ones will be associated to rules or to characteristics
59 * (see {@link Measure#equals(Object)}.
62 Set<Measure> getRawMeasures(Component component, Metric metric);
65 * Returns the {@link Measure}s for the specified {@link Component} mapped by their metric key.
67 * Their can be multiple measures for the same Metric but only one which has no rule nor characteristic, one with a
68 * specific ruleId and one with specific characteristicId (see {@link Measure#equals(Object)}.
71 SetMultimap<String, Measure> getRawMeasures(Component component);
74 * Adds the specified measure for the specified Component and Metric. There can be no more than one measure for a
75 * specific combination of Component, Metric and association to a specific rule or characteristic.
77 * @throws NullPointerException if any of the arguments is null
78 * @throws UnsupportedOperationException when trying to add a measure when one already exists for the specified Component/Metric paar
80 void add(Component component, Metric metric, Measure measure);
83 * Updates the specified measure for the specified Component and Metric. There can be no more than one measure for a
84 * specific combination of Component, Metric and association to a specific rule or characteristic.
86 * @throws NullPointerException if any of the arguments is null
87 * @throws UnsupportedOperationException when trying to update a non existing measure
89 void update(Component component, Metric metric, Measure measure);