From 7229de6b303f8962ade62410664b669835c62632 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 10 Jun 2013 15:31:52 +0200 Subject: [PATCH] Set list of status as constant --- .../main/java/org/sonar/api/rules/Rule.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java index 7bc4e18671c..71c4e9f3a4f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java @@ -62,6 +62,12 @@ public final class Rule { */ public static final String STATUS_REMOVED = "REMOVED"; + /** + * List of available status + * @since 3.6 + */ + private static final Set STATUS_LIST = ImmutableSet.of(STATUS_READY, STATUS_BETA, STATUS_DEPRECATED, STATUS_REMOVED); + @Id @Column(name = "id") @@ -82,7 +88,6 @@ public final class Rule { @Column(name = "plugin_config_key", updatable = true, nullable = true, length = 500) private String configKey; - // Godin: This field should be named priority, otherwise StandardRulesXmlParserTest fails @Column(name = "priority", updatable = true, nullable = true) @Enumerated(EnumType.ORDINAL) private RulePriority priority = DEFAULT_PRIORITY; @@ -124,7 +129,7 @@ public final class Rule { */ @Deprecated public Rule() { - // TODO reduce visibility to package + // TODO reduce visibility to packaete } /** @@ -405,8 +410,8 @@ public final class Rule { * @since 3.6 */ public Rule setStatus(String status) { - if (!getStatusList().contains(status)) { - throw new SonarException("The status of a rule can only contain : " + Joiner.on(", ").join(getStatusList())); + if (!STATUS_LIST.contains(status)) { + throw new SonarException("The status of a rule can only contain : " + Joiner.on(", ").join(STATUS_LIST)); } this.status = status; return this; @@ -526,13 +531,6 @@ public final class Rule { return new Rule().setUniqueKey(repositoryKey, key); } - /** - * @since 3.6 - */ - public static Set getStatusList() { - return ImmutableSet.of(STATUS_READY, STATUS_BETA, STATUS_DEPRECATED, STATUS_REMOVED); - } - /** * @since 3.6 */ -- 2.39.5