aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);