aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-22 12:32:49 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-22 12:32:49 +0000
commit9efe7e5d788f6a7d0de0bb3c2bc0cdf84496b021 (patch)
treefb90f30bf9d7ca0e3e2546c93ccc26244ca6a71d
parent7bcadee385ef8b8d5ec2ef49ed594ee9accdc49c (diff)
downloadsonarqube-9efe7e5d788f6a7d0de0bb3c2bc0cdf84496b021.tar.gz
sonarqube-9efe7e5d788f6a7d0de0bb3c2bc0cdf84496b021.zip
add factory methods to org.sonar.api.qualitymodel.Characteristic
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java2
2 files changed, 13 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
index 8a6d70fd953..4a1053c88a2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
@@ -314,4 +314,16 @@ public final class Characteristic implements Comparable<Characteristic> {
}
return order - o.order;
}
+
+ public static Characteristic createByName(String name) {
+ return new Characteristic().setName(name, true);
+ }
+
+ public static Characteristic createByKey(String key, String name) {
+ return new Characteristic().setKey(key).setName(name, false);
+ }
+
+ public static Characteristic createByRule(Rule rule) {
+ return new Characteristic().setRule(rule);
+ }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
index ef515f96bbf..2cd4f1f86bf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
@@ -97,7 +97,7 @@ public final class Model implements Comparable<Model> {
return this;
}
- private Characteristic addCharacteristic(Characteristic c) {
+ public Characteristic addCharacteristic(Characteristic c) {
c.setModel(this);
c.setOrder(characteristics.size() + 1);
characteristics.add(c);