From c9e8a83160caad699bc34ed2df114dfa40bc855c Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Tue, 16 Jan 2024 13:54:02 +0100 Subject: [PATCH] Lets use boolean instead of Boolean wrapper (cherry picked from commit c54a39b0aedc217ad8f65ee820f6a6918aed2268) --- .../java/play/db/ebean/DefaultEbeanConfig.java | 11 +++++++---- .../src/main/java/play/db/ebean/EbeanConfig.java | 3 ++- .../play/db/ebean/EbeanDynamicEvolutions.java | 2 +- .../java/play/db/ebean/EbeanParsedConfig.java | 15 +++++++-------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/play-ebean/src/main/java/play/db/ebean/DefaultEbeanConfig.java b/play-ebean/src/main/java/play/db/ebean/DefaultEbeanConfig.java index ccb7186..e7fe434 100644 --- a/play-ebean/src/main/java/play/db/ebean/DefaultEbeanConfig.java +++ b/play-ebean/src/main/java/play/db/ebean/DefaultEbeanConfig.java @@ -24,16 +24,17 @@ /** Ebean server configuration. */ @Singleton public class DefaultEbeanConfig implements EbeanConfig { + private final String defaultServer; private final Map serverConfigs; - private final Boolean generateEvolutionsScripts; + private final boolean generateEvolutionsScripts; public DefaultEbeanConfig( String defaultServer, Map serverConfigs, - Boolean generateEvolutionsScripts) { + boolean generateEvolutionsScripts) { this.defaultServer = defaultServer; this.serverConfigs = serverConfigs; this.generateEvolutionsScripts = generateEvolutionsScripts; @@ -54,13 +55,12 @@ public Map serverConfigs() { } @Override - public Boolean generateEvolutionsScripts() { + public boolean generateEvolutionsScripts() { return generateEvolutionsScripts; } @Singleton public static class EbeanConfigParser implements Provider { - private static final Logger.ALogger LOGGER = Logger.of(DefaultEbeanConfig.class); private final Config config; @@ -68,6 +68,8 @@ public static class EbeanConfigParser implements Provider { private final DBApi dbApi; + private static final Logger.ALogger LOGGER = Logger.of(DefaultEbeanConfig.class); + @Inject public EbeanConfigParser(Config config, Environment environment, DBApi dbApi) { this.config = config; @@ -86,6 +88,7 @@ public EbeanConfig get() { * @return a config for Ebean servers. */ public EbeanConfig parse() { + EbeanParsedConfig ebeanConfig = EbeanParsedConfig.parseFromConfig(config); Map serverConfigs = new HashMap<>(); diff --git a/play-ebean/src/main/java/play/db/ebean/EbeanConfig.java b/play-ebean/src/main/java/play/db/ebean/EbeanConfig.java index f28bf29..f2a2b4f 100644 --- a/play-ebean/src/main/java/play/db/ebean/EbeanConfig.java +++ b/play-ebean/src/main/java/play/db/ebean/EbeanConfig.java @@ -8,9 +8,10 @@ import java.util.Map; public interface EbeanConfig { + String defaultServer(); Map serverConfigs(); - Boolean generateEvolutionsScripts(); + boolean generateEvolutionsScripts(); } diff --git a/play-ebean/src/main/java/play/db/ebean/EbeanDynamicEvolutions.java b/play-ebean/src/main/java/play/db/ebean/EbeanDynamicEvolutions.java index 8fda66b..dcb47cc 100644 --- a/play-ebean/src/main/java/play/db/ebean/EbeanDynamicEvolutions.java +++ b/play-ebean/src/main/java/play/db/ebean/EbeanDynamicEvolutions.java @@ -64,7 +64,7 @@ public void create() { if (environment.isProd()) { return; } - if (Boolean.FALSE.equals(config.generateEvolutionsScripts())) { + if (!config.generateEvolutionsScripts()) { return; } config diff --git a/play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java b/play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java index 25631f6..941e7bf 100644 --- a/play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java +++ b/play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java @@ -16,16 +16,17 @@ * database connection pools to create. */ public class EbeanParsedConfig { + private final String defaultDatasource; private final Map> datasourceModels; - private final Boolean generateEvolutionsScripts; + private final boolean generateEvolutionsScripts; public EbeanParsedConfig( String defaultDatasource, Map> datasourceModels, - Boolean generateEvolutionsScripts) { + boolean generateEvolutionsScripts) { this.defaultDatasource = defaultDatasource; this.datasourceModels = datasourceModels; this.generateEvolutionsScripts = generateEvolutionsScripts; @@ -43,7 +44,7 @@ public Map> getDatasourceModels() { return datasourceModels; } - public Boolean generateEvolutionsScripts() { + public boolean generateEvolutionsScripts() { return generateEvolutionsScripts; } @@ -56,10 +57,9 @@ public Boolean generateEvolutionsScripts() { */ public static EbeanParsedConfig parseFromConfig(Config config) { Config playEbeanConfig = config.getConfig("play.ebean"); + String defaultDatasource = playEbeanConfig.getString("defaultDatasource"); String ebeanConfigKey = playEbeanConfig.getString("config"); - String ebeanDefaultDatasource = playEbeanConfig.getString("defaultDatasource"); - Boolean ebeanGenerateEvolutionsScripts = - playEbeanConfig.getBoolean("generateEvolutionsScripts"); + boolean generateEvolutionsScripts = playEbeanConfig.getBoolean("generateEvolutionsScripts"); Map> datasourceModels = new HashMap<>(); @@ -80,7 +80,6 @@ public static EbeanParsedConfig parseFromConfig(Config config) { datasourceModels.put(key, models); }); } - return new EbeanParsedConfig( - ebeanDefaultDatasource, datasourceModels, ebeanGenerateEvolutionsScripts); + return new EbeanParsedConfig(defaultDatasource, datasourceModels, generateEvolutionsScripts); } }