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.

Metric.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2020 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.metric;
  21. import javax.annotation.CheckForNull;
  22. import org.sonar.ce.task.projectanalysis.measure.Measure;
  23. public interface Metric {
  24. /**
  25. * The metric's id (ie. its database identifier)
  26. */
  27. int getId();
  28. /**
  29. * The Metric's key is its domain identifier.
  30. */
  31. String getKey();
  32. String getName();
  33. MetricType getType();
  34. /**
  35. * When Metric is "bestValueOptimized" _and_ the component it belongs to is a FILE, any measure which has the same
  36. * value as the best value of the metric should _not_ be persisted into the DB to save on DB usage.
  37. */
  38. boolean isBestValueOptimized();
  39. /**
  40. * The best value for the current Metric, if there is any
  41. */
  42. @CheckForNull
  43. Double getBestValue();
  44. /**
  45. * The decimal scale of float measures. Returned value is greater than or equal zero.
  46. * @throws IllegalStateException if the value type is not decimal (see {@link org.sonar.ce.task.projectanalysis.measure.Measure.ValueType}
  47. */
  48. int getDecimalScale();
  49. boolean isDeleteHistoricalData();
  50. enum MetricType {
  51. INT(Measure.ValueType.INT),
  52. MILLISEC(Measure.ValueType.LONG),
  53. RATING(Measure.ValueType.INT),
  54. WORK_DUR(Measure.ValueType.LONG),
  55. FLOAT(Measure.ValueType.DOUBLE),
  56. PERCENT(Measure.ValueType.DOUBLE),
  57. BOOL(Measure.ValueType.BOOLEAN),
  58. STRING(Measure.ValueType.STRING),
  59. DISTRIB(Measure.ValueType.STRING),
  60. DATA(Measure.ValueType.STRING),
  61. LEVEL(Measure.ValueType.LEVEL);
  62. private final Measure.ValueType valueType;
  63. MetricType(Measure.ValueType valueType) {
  64. this.valueType = valueType;
  65. }
  66. public Measure.ValueType getValueType() {
  67. return valueType;
  68. }
  69. }
  70. }