diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-26 01:14:52 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-26 01:14:52 +0100 |
commit | 4bb50d01dcb3e31939bb1bdaa646c971664ab7a8 (patch) | |
tree | 95f99e3c886f562bfa3e8b984d660f6516756886 /sonar-plugin-api | |
parent | a1473df87a3dedafdf3c5f663caddec1384bea09 (diff) | |
download | sonarqube-4bb50d01dcb3e31939bb1bdaa646c971664ab7a8.tar.gz sonarqube-4bb50d01dcb3e31939bb1bdaa646c971664ab7a8.zip |
SONAR-1914 reload measures with PersistenceMode.DATABASE on demand
Diffstat (limited to 'sonar-plugin-api')
4 files changed, 33 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index 59c1f66ed9a..b33487af40f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -600,6 +600,7 @@ public final class CoreMetrics { // SCM + // These metrics are computed by the SCM Activity plugin, since version 1.2. public static final String SCM_COMMITS_KEY = "commits"; public static final Metric SCM_COMMITS = new Metric.Builder(SCM_COMMITS_KEY, Metric.ValueType.INT) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 3b64b89da3f..6462db590d5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -323,6 +323,14 @@ public class Measure { } /** + * @since 2.7 + */ + public Measure unsetData() { + this.data=null; + return this; + } + + /** * @return the description of the measure */ public String getDescription() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index 92050c92d81..e0ec08d89aa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -130,7 +130,9 @@ public class Metric implements ServerExtension, BatchExtension { * Creates a metric based on its key. Shortcut to Metric(key, ValueType.INT) * * @param key the metric key + * @deprecated since 2.7 use the Builder factory. */ + @Deprecated public Metric(String key) { this(key, ValueType.INT); } @@ -141,11 +143,17 @@ public class Metric implements ServerExtension, BatchExtension { * * @param key the key * @param type the type + * @deprecated since 2.7 use the Builder factory. */ + @Deprecated public Metric(String key, ValueType type) { this(key, key, key, type, -1, Boolean.FALSE, null, false); } + /** + * @deprecated since 2.7 use the Builder factory. + */ + @Deprecated public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain) { this(key, name, description, type, direction, qualitative, domain, false); } @@ -164,6 +172,7 @@ public class Metric implements ServerExtension, BatchExtension { * @param qualitative whether the metric is qualitative * @param domain the metric domain * @param userManaged whether the metric is user managed + * @deprecated since 2.7 use the Builder factory. */ @Deprecated public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain, boolean userManaged) { @@ -197,7 +206,9 @@ public class Metric implements ServerExtension, BatchExtension { * @param qualitative whether the metric is qualitative * @param domain the metric domain * @param formula the metric formula + * @deprecated since 2.7 use the Builder factory. */ + @Deprecated public Metric(String key, String name, ValueType type, Integer direction, Boolean qualitative, String domain, Formula formula) { this.key = key; this.name = name; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java index 50f2a329574..6a29f0c1c22 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java @@ -114,4 +114,17 @@ public class MeasureTest { assertFalse(measure.equals(ruleMeasure)); assertFalse(ruleMeasure.equals(measure)); } + + @Test + public void shouldUnsetData() { + String data = "1=10;21=456"; + Measure measure = new Measure(CoreMetrics.CONDITIONS_BY_LINE).setData( data); + assertThat(measure.hasData(), is(true)); + assertThat(measure.getData(), is(data)); + + measure.unsetData(); + + assertThat(measure.hasData(), is(false)); + assertThat(measure.getData(), nullValue()); + } } |