diff options
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java | 41 |
1 files changed, 28 insertions, 13 deletions
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 95035b48bcd..6c98862765d 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 @@ -23,8 +23,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.batch.BatchSide; -import org.sonar.api.server.ServerSide; import org.sonar.api.batch.InstantiationStrategy; +import org.sonar.api.server.ServerSide; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -65,28 +65,43 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a public static final int DIRECTION_NONE = 0; public enum ValueType { - INT(Integer.class), - FLOAT(Double.class), - PERCENT(Double.class), - BOOL(Boolean.class), - STRING(String.class), - MILLISEC(Integer.class), - DATA(String.class), - LEVEL(Metric.Level.class), - DISTRIB(String.class), - RATING(Integer.class), - WORK_DUR(Long.class); + INT(Integer.class, "Integer"), + FLOAT(Double.class, "Float"), + PERCENT(Double.class, "Percent"), + BOOL(Boolean.class, "Yes/No"), + STRING(String.class, "String"), + MILLISEC(Integer.class, "Milliseconds"), + DATA(String.class, "Data"), + LEVEL(Metric.Level.class, "Level"), + DISTRIB(String.class, "Distribution"), + RATING(Integer.class, "Rating"), + WORK_DUR(Long.class, "Work Duration"); private final Class valueClass; + private final String description; - private ValueType(Class valueClass) { + ValueType(Class valueClass, String description) { this.valueClass = valueClass; + this.description = description; } private Class valueType() { return valueClass; } + public String description() { + return description; + } + + public static String descriptionOf(String key) { + for (ValueType valueType : values()) { + if (valueType.name().equals(key)) { + return valueType.description; + } + } + + throw new IllegalArgumentException(String.format("Unknown ValueType key '%s'", key)); + } } public enum Level { |