diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-04-06 10:31:09 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-04-06 10:31:15 +0200 |
commit | c7662baa5b3c54e0627f88796728e2e0da1f70fb (patch) | |
tree | c617fec7dc8da19a21e7003602489f0eb4eef11e /sonar-plugin-api/src/main/java/org/sonar/api/rules | |
parent | 9e8e346e71b304fcf7aeb4e4f4c9a3c7107e1a53 (diff) | |
download | sonarqube-c7662baa5b3c54e0627f88796728e2e0da1f70fb.tar.gz sonarqube-c7662baa5b3c54e0627f88796728e2e0da1f70fb.zip |
Fix quality flaws
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/rules')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleType.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleType.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleType.java index 66222702a69..5755b8050fb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleType.java @@ -19,16 +19,18 @@ */ package org.sonar.api.rules; -import com.google.common.base.Enums; -import com.google.common.collect.Lists; -import java.util.List; +import com.google.common.base.Function; +import java.util.Arrays; +import java.util.Set; +import javax.annotation.Nonnull; +import static com.google.common.collect.FluentIterable.from; import static java.lang.String.format; public enum RuleType { CODE_SMELL(1), BUG(2), VULNERABILITY(3); - public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(RuleType.class).reverse()); + private static final Set<String> ALL_NAMES = from(Arrays.asList(values())).transform(ToName.INSTANCE).toSet(); private final int dbConstant; @@ -40,6 +42,10 @@ public enum RuleType { return dbConstant; } + public static Set<String> names() { + return ALL_NAMES; + } + /** * Returns the enum constant of the specified DB column value. */ @@ -53,4 +59,13 @@ public enum RuleType { throw new IllegalArgumentException(format("Unsupported type value : %d", dbConstant)); } + private enum ToName implements Function<RuleType, String> { + INSTANCE; + + @Override + public String apply(@Nonnull RuleType input) { + return input.name(); + } + } + } |