diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-06-29 18:13:15 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2017-07-04 23:47:46 +0200 |
commit | 5694a472f1f507f80c7aad3edee93df95a23a4c2 (patch) | |
tree | d8ba063d3bc7d3f65f65dc737287cf5b980d2879 /sonar-plugin-api/src | |
parent | 4ad21e8bc6085cb13d16e5b7e68b475296833bd2 (diff) | |
download | sonarqube-5694a472f1f507f80c7aad3edee93df95a23a4c2.tar.gz sonarqube-5694a472f1f507f80c7aad3edee93df95a23a4c2.zip |
SONAR-9478 Replace Settings by Configuration
Diffstat (limited to 'sonar-plugin-api/src')
4 files changed, 26 insertions, 7 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java index dae2594593a..f079a49dc67 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java @@ -53,10 +53,10 @@ public class EmailSettings { public static final String PREFIX = "email.prefix"; public static final String PREFIX_DEFAULT = "[SONARQUBE]"; - private final Settings settings; + private final Configuration config; - public EmailSettings(Settings settings) { - this.settings = settings; + public EmailSettings(Configuration config) { + this.config = config; } public String getSmtpHost() { @@ -92,8 +92,7 @@ public class EmailSettings { } private String get(String key, String defaultValue) { - String value = settings.getString(key); - return value != null ? value : defaultValue; + return config.get(key).orElse(defaultValue); } /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java index 13c407d000b..d15b7c1a65b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java @@ -57,7 +57,7 @@ import static org.sonar.api.PropertyType.REGULAR_EXPRESSION; import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST; /** - * Declare a plugin property. Values are available at runtime through the components {@link Settings} or {@link org.sonar.api.Configuration.SettingsReader}. + * Declare a plugin property. Values are available at runtime through the component {@link Configuration}. * <br> * It's the programmatic alternative to the annotation {@link org.sonar.api.Property}. It is more * testable and adds new features like sub-categories and ordering. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java index 6d45e12ddb6..9a58e9eb6a0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java @@ -79,6 +79,26 @@ public class MapSettings extends Settings { return this; } + @Override + public MapSettings setProperty(String key, String value) { + return (MapSettings) super.setProperty(key, value); + } + + @Override + public MapSettings setProperty(String key, Integer value) { + return (MapSettings) super.setProperty(key, value); + } + + @Override + public MapSettings setProperty(String key, Boolean value) { + return (MapSettings) super.setProperty(key, value); + } + + @Override + public MapSettings setProperty(String key, Long value) { + return (MapSettings) super.setProperty(key, value); + } + /** * @return a {@link Configuration} proxy on top of this existing {@link Settings} implementation. Changes are reflected in the {@link Configuration} object. * @since 6.5 diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java index 507ab123b08..0ce63c67563 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java @@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class EmailSettingsTest { - private EmailSettings underTest = new EmailSettings(new MapSettings()); + private EmailSettings underTest = new EmailSettings(new MapSettings().asConfig()); @Test public void should_return_default_values() { |