You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MeasureRepository.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  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.
  10. *
  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.
  15. *
  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.
  19. */
  20. package org.sonar.ce.task.projectanalysis.measure;
  21. import com.google.common.collect.SetMultimap;
  22. import java.util.Optional;
  23. import java.util.Set;
  24. import org.sonar.ce.task.projectanalysis.component.Component;
  25. import org.sonar.ce.task.projectanalysis.metric.Metric;
  26. import org.sonar.ce.task.projectanalysis.metric.MetricImpl;
  27. public interface MeasureRepository {
  28. /**
  29. * Retrieves the base measure (ie. the one currently existing in DB) for the specified {@link Component} for
  30. * the specified {@link MetricImpl} if it exists.
  31. * <p>
  32. * This method searches for Measure which are specific to the Component.
  33. * </p>
  34. *
  35. * @throws NullPointerException if either argument is {@code null}
  36. */
  37. Optional<Measure> getBaseMeasure(Component component, Metric metric);
  38. /**
  39. * Retrieves the measure created during the current analysis for the specified {@link Component} for the specified
  40. * {@link Metric} if it exists (ie. one created by the Compute Engine or the Scanner).
  41. */
  42. Optional<Measure> getRawMeasure(Component component, Metric metric);
  43. /**
  44. * Returns the {@link Measure}s for the specified {@link Component} and the specified {@link Metric}.
  45. */
  46. Set<Measure> getRawMeasures(Component component, Metric metric);
  47. /**
  48. * Returns the {@link Measure}s for the specified {@link Component} mapped by their metric key.
  49. */
  50. SetMultimap<String, Measure> getRawMeasures(Component component);
  51. /**
  52. * Adds the specified measure for the specified Component and Metric. There can be no more than one measure for a
  53. * specific combination of Component, Metric.
  54. *
  55. * @throws NullPointerException if any of the arguments is null
  56. * @throws UnsupportedOperationException when trying to add a measure when one already exists for the specified Component/Metric paar
  57. */
  58. void add(Component component, Metric metric, Measure measure);
  59. /**
  60. * Updates the specified measure for the specified Component and Metric. There can be no more than one measure for a
  61. * specific combination of Component, Metric.
  62. *
  63. * @throws NullPointerException if any of the arguments is null
  64. * @throws UnsupportedOperationException when trying to update a non existing measure
  65. */
  66. void update(Component component, Metric metric, Measure measure);
  67. }