From d217475442c8b463724626325f27ff5bfe06fc14 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 11 Jul 2013 17:10:08 +0200 Subject: Add some CheckForNull and Nullable annotations --- .../src/main/java/org/sonar/api/i18n/I18n.java | 6 +++++- .../src/main/java/org/sonar/api/i18n/RuleI18n.java | 5 +++++ .../main/java/org/sonar/api/i18n/package-info.java | 23 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/i18n/package-info.java (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/i18n') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java index 7ce619b9c42..2588ea5d58f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java @@ -22,6 +22,9 @@ package org.sonar.api.i18n; import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + import java.util.Locale; /** @@ -45,6 +48,7 @@ public interface I18n extends ServerComponent, BatchComponent { * @param parameters the parameters used to format the message from the translated pattern. * @return the message formatted with the translated pattern and the given parameters */ - String message(final Locale locale, final String key, final String defaultValue, final Object... parameters); + @CheckForNull + String message(final Locale locale, final String key, @Nullable final String defaultValue, final Object... parameters); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java index 5cb5e002187..9b06cee3180 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java @@ -23,6 +23,8 @@ import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; import org.sonar.api.rules.Rule; +import javax.annotation.CheckForNull; + import java.util.Locale; /** @@ -43,6 +45,7 @@ public interface RuleI18n extends ServerComponent, BatchComponent { * @param locale the locale to translate into * @return the translated name of the rule, or the default English one if the given locale is not supported, or null */ + @CheckForNull String getName(String repositoryKey, String ruleKey, Locale locale); /** @@ -55,6 +58,7 @@ public interface RuleI18n extends ServerComponent, BatchComponent { * @param locale the locale to translate into * @return the translated name of the rule, or the default English one if the given locale is not supported, or the rule name. */ + @CheckForNull String getName(Rule rule, Locale locale); /** @@ -83,6 +87,7 @@ public interface RuleI18n extends ServerComponent, BatchComponent { * @return the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if * no translation can be found. */ + @CheckForNull String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/package-info.java new file mode 100644 index 00000000000..616332a1c32 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.api.i18n; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file -- cgit v1.2.3