diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 10:00:37 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 10:19:37 +0200 |
commit | 01afdb26e9e5a6174a6d5cb51f6dc92ad9f420f3 (patch) | |
tree | 6c95a5a73df700f1920c3047c10295e06d48f4a3 | |
parent | e62ad022b7a4d608066eb2496e9f8c9767cb829b (diff) | |
download | sonarqube-01afdb26e9e5a6174a6d5cb51f6dc92ad9f420f3.tar.gz sonarqube-01afdb26e9e5a6174a6d5cb51f6dc92ad9f420f3.zip |
SONAR-5389 Flag API as @Beta
21 files changed, 59 insertions, 27 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/languages/Language.java b/sonar-batch/src/main/java/org/sonar/api/batch/languages/Language.java index 726c95152cc..726c95152cc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/languages/Language.java +++ b/sonar-batch/src/main/java/org/sonar/api/batch/languages/Language.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/languages/package-info.java b/sonar-batch/src/main/java/org/sonar/api/batch/languages/package-info.java index 40c79e60c99..40c79e60c99 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/languages/package-info.java +++ b/sonar-batch/src/main/java/org/sonar/api/batch/languages/package-info.java diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index 2f35ec81bc0..f8e1dc601e3 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -178,7 +178,7 @@ public class DefaultIndex extends SonarIndex { } @Override - public Measure getMeasure(Resource resource, org.sonar.api.batch.measures.Metric<?> metric) { + public Measure getMeasure(Resource resource, org.sonar.api.batch.measure.Metric<?> metric) { return getMeasures(resource, MeasuresFilters.metric(metric)); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java index c83c090f252..b4231b5c252 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan; +import org.sonar.api.batch.measure.Metric; + import org.sonar.api.batch.SensorContext; import org.sonar.api.batch.analyzer.AnalyzerContext; import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; @@ -29,7 +31,6 @@ import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasureBuilder; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.component.ResourcePerspectives; import org.sonar.api.config.Settings; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java index 6f2e09acc3f..1f5408c2002 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan; +import org.sonar.api.batch.measure.Metric; + import org.sonar.api.batch.DependedUpon; import org.sonar.api.batch.DependsUpon; import org.sonar.api.batch.Sensor; @@ -27,7 +29,6 @@ import org.sonar.api.batch.analyzer.Analyzer; import org.sonar.api.batch.analyzer.AnalyzerContext; import org.sonar.api.batch.analyzer.internal.DefaultAnalyzerDescriptor; import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.batch.scan2.AnalyzerOptimizer; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java index e411fbbfe74..1ec141ada84 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan2; +import org.sonar.api.batch.measure.Metric; + import org.sonar.api.batch.analyzer.AnalyzerContext; import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder; @@ -30,7 +32,6 @@ import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasureBuild import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Settings; import org.sonar.api.issue.internal.DefaultIssue; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java index b4cba728060..f52fcb98f0a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java @@ -120,7 +120,7 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe public abstract Resource addResource(Resource resource); @CheckForNull - public abstract Measure getMeasure(Resource resource, org.sonar.api.batch.measures.Metric<?> metric); + public abstract Measure getMeasure(Resource resource, org.sonar.api.batch.measure.Metric<?> metric); @CheckForNull public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/Analyzer.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/Analyzer.java index 6a67d29040f..c551226895c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/Analyzer.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/Analyzer.java @@ -19,6 +19,7 @@ */ package org.sonar.api.batch.analyzer; +import com.google.common.annotations.Beta; import org.sonar.api.BatchExtension; /** @@ -33,6 +34,7 @@ import org.sonar.api.BatchExtension; * * @since 4.4 */ +@Beta public interface Analyzer extends BatchExtension { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java index b28ab8af61b..4f013555766 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java @@ -19,13 +19,15 @@ */ package org.sonar.api.batch.analyzer; +import org.sonar.api.batch.measure.Metric; + +import com.google.common.annotations.Beta; import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Settings; @@ -36,6 +38,7 @@ import java.io.Serializable; /** * @since 4.4 */ +@Beta public interface AnalyzerContext { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java index ab52f9a8b80..8038bac43ce 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java @@ -19,15 +19,17 @@ */ package org.sonar.api.batch.analyzer; +import org.sonar.api.batch.measure.Metric; + +import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.languages.Language; -import org.sonar.api.batch.measures.Metric; /** * Describe what an {@link Analyzer} is doing. Information may be used by the platform * to log interesting information or perform some optimization. * @since 4.4 */ +@Beta public interface AnalyzerDescriptor { /** @@ -46,7 +48,7 @@ public interface AnalyzerDescriptor { AnalyzerDescriptor provides(Metric<?>... metrics); /** - * List {@link Language} this {@link Analyzer} work on. May be used by the platform to skip execution of the {@link Analyzer} when + * List languages this {@link Analyzer} work on. May be used by the platform to skip execution of the {@link Analyzer} when * no file for given languages are present in the project. * If no language is provided then it will be executed for all languages. */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptor.java index 9fc41b65dd0..dea8593013f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptor.java @@ -19,9 +19,10 @@ */ package org.sonar.api.batch.analyzer.internal; +import org.sonar.api.batch.measure.Metric; + import org.sonar.api.batch.analyzer.AnalyzerDescriptor; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import java.util.Arrays; import java.util.Collection; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssue.java index ed1de433607..9a9ce1bcaee 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssue.java @@ -19,6 +19,7 @@ */ package org.sonar.api.batch.analyzer.issue; +import com.google.common.annotations.Beta; import org.sonar.api.batch.analyzer.Analyzer; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.rule.RuleKey; @@ -30,6 +31,7 @@ import javax.annotation.Nullable; * * @since 4.4 */ +@Beta public interface AnalyzerIssue { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java index 5c272632984..0955c953725 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java @@ -19,6 +19,7 @@ */ package org.sonar.api.batch.analyzer.issue; +import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.rule.RuleKey; @@ -29,6 +30,7 @@ import javax.annotation.Nullable; * * @since 4.4 */ +@Beta public interface AnalyzerIssueBuilder { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasure.java index 554efed34de..ccfc5a83c5d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasure.java @@ -19,9 +19,11 @@ */ package org.sonar.api.batch.analyzer.measure; +import org.sonar.api.batch.measure.Metric; + +import com.google.common.annotations.Beta; import org.sonar.api.batch.analyzer.Analyzer; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import javax.annotation.Nullable; @@ -31,6 +33,7 @@ import java.io.Serializable; * A measure computed by an {@link Analyzer}. * @since 4.4 */ +@Beta public interface AnalyzerMeasure<G extends Serializable> { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasureBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasureBuilder.java index 7e94051bd7c..b837f85ab85 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasureBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/AnalyzerMeasureBuilder.java @@ -19,8 +19,10 @@ */ package org.sonar.api.batch.analyzer.measure; +import org.sonar.api.batch.measure.Metric; + +import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import java.io.Serializable; @@ -28,6 +30,7 @@ import java.io.Serializable; * Builder to create new {@link AnalyzerMeasure} * @since 4.4 */ +@Beta public interface AnalyzerMeasureBuilder<G extends Serializable> { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasure.java index fa87d0953c9..e9e9be05f61 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasure.java @@ -19,10 +19,11 @@ */ package org.sonar.api.batch.analyzer.measure.internal; +import org.sonar.api.batch.measure.Metric; + import com.google.common.base.Preconditions; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import javax.annotation.Nullable; @@ -36,7 +37,8 @@ public class DefaultAnalyzerMeasure<G extends Serializable> implements AnalyzerM DefaultAnalyzerMeasure(DefaultAnalyzerMeasureBuilder<G> builder) { Preconditions.checkNotNull(builder.value, "Measure value can't be null"); - Preconditions.checkNotNull(builder.metric, "Measure metricKey can't be null"); + Preconditions.checkNotNull(builder.metric, "Measure metric can't be null"); + Preconditions.checkState(builder.metric.valueType().equals(builder.value.getClass()), "Measure value should be of type " + builder.metric.valueType()); this.inputFile = builder.file; this.metric = builder.metric; this.value = builder.value; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java index 4eea5eb624d..c482d1f5166 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java @@ -19,11 +19,12 @@ */ package org.sonar.api.batch.analyzer.measure.internal; +import org.sonar.api.batch.measure.Metric; + import com.google.common.base.Preconditions; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measures.Metric; import java.io.Serializable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/Metric.java index 6b8d0445dcd..e5e4f98953b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/Metric.java @@ -17,13 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.batch.measures; +package org.sonar.api.batch.measure; + +import com.google.common.annotations.Beta; import java.io.Serializable; +/** + * Metric definition. + * @since 4.4 + */ +@Beta public interface Metric<G extends Serializable> { - Class<G> type(); - String key(); + + Class<G> valueType(); + } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measures/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java index ae11775ae05..ab3c359ded8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measures/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java @@ -18,4 +18,4 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @javax.annotation.ParametersAreNonnullByDefault -package org.sonar.api.batch.measures;
\ No newline at end of file +package org.sonar.api.batch.measure;
\ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index 53407b9136d..15812bbafe9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -51,7 +51,7 @@ public final class MeasuresFilters { }; } - public static MeasuresFilter<Measure> metric(final org.sonar.api.batch.measures.Metric<?> metric) { + public static MeasuresFilter<Measure> metric(final org.sonar.api.batch.measure.Metric<?> metric) { return metric(metric.key()); } 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 ccd4d8c8d50..4f5493f88a9 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 @@ -46,7 +46,7 @@ import java.io.Serializable; @Table(name = "metrics") @Entity(name = "Metric") @InstantiationStrategy(InstantiationStrategy.PER_BATCH) -public class Metric<G extends Serializable> implements ServerExtension, BatchExtension, Serializable, org.sonar.api.batch.measures.Metric<G> { +public class Metric<G extends Serializable> implements ServerExtension, BatchExtension, Serializable, org.sonar.api.batch.measure.Metric<G> { /** * A metric bigger value means a degradation @@ -74,14 +74,14 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt RATING(String.class), WORK_DUR(Long.class); - private final Class measureJavaType; + private final Class valueType; private ValueType(Class measureJavaType) { - this.measureJavaType = measureJavaType; + this.valueType = measureJavaType; } - private Class measureJavaType() { - return measureJavaType; + private Class valueType() { + return valueType; } } @@ -802,7 +802,7 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt } @Override - public Class<G> type() { - return getType().measureJavaType(); + public Class<G> valueType() { + return getType().valueType(); } } |