Skip to content

Commit

Permalink
Lets use boolean instead of Boolean wrapper
Browse files Browse the repository at this point in the history
(cherry picked from commit c54a39b)
  • Loading branch information
mkurz authored and mergify[bot] committed Jan 16, 2024
1 parent 3352d9d commit c9e8a83
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
11 changes: 7 additions & 4 deletions play-ebean/src/main/java/play/db/ebean/DefaultEbeanConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
/** Ebean server configuration. */
@Singleton
public class DefaultEbeanConfig implements EbeanConfig {

private final String defaultServer;

private final Map<String, DatabaseConfig> serverConfigs;

private final Boolean generateEvolutionsScripts;
private final boolean generateEvolutionsScripts;

public DefaultEbeanConfig(
String defaultServer,
Map<String, DatabaseConfig> serverConfigs,
Boolean generateEvolutionsScripts) {
boolean generateEvolutionsScripts) {
this.defaultServer = defaultServer;
this.serverConfigs = serverConfigs;
this.generateEvolutionsScripts = generateEvolutionsScripts;
Expand All @@ -54,20 +55,21 @@ public Map<String, DatabaseConfig> serverConfigs() {
}

@Override
public Boolean generateEvolutionsScripts() {
public boolean generateEvolutionsScripts() {
return generateEvolutionsScripts;
}

@Singleton
public static class EbeanConfigParser implements Provider<EbeanConfig> {
private static final Logger.ALogger LOGGER = Logger.of(DefaultEbeanConfig.class);

private final Config config;

private final Environment environment;

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;
Expand All @@ -86,6 +88,7 @@ public EbeanConfig get() {
* @return a config for Ebean servers.
*/
public EbeanConfig parse() {

EbeanParsedConfig ebeanConfig = EbeanParsedConfig.parseFromConfig(config);

Map<String, DatabaseConfig> serverConfigs = new HashMap<>();
Expand Down
3 changes: 2 additions & 1 deletion play-ebean/src/main/java/play/db/ebean/EbeanConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import java.util.Map;

public interface EbeanConfig {

String defaultServer();

Map<String, DatabaseConfig> serverConfigs();

Boolean generateEvolutionsScripts();
boolean generateEvolutionsScripts();
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void create() {
if (environment.isProd()) {
return;
}
if (Boolean.FALSE.equals(config.generateEvolutionsScripts())) {
if (!config.generateEvolutionsScripts()) {
return;
}
config
Expand Down
15 changes: 7 additions & 8 deletions play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
* database connection pools to create.
*/
public class EbeanParsedConfig {

private final String defaultDatasource;

private final Map<String, List<String>> datasourceModels;

private final Boolean generateEvolutionsScripts;
private final boolean generateEvolutionsScripts;

public EbeanParsedConfig(
String defaultDatasource,
Map<String, List<String>> datasourceModels,
Boolean generateEvolutionsScripts) {
boolean generateEvolutionsScripts) {
this.defaultDatasource = defaultDatasource;
this.datasourceModels = datasourceModels;
this.generateEvolutionsScripts = generateEvolutionsScripts;
Expand All @@ -43,7 +44,7 @@ public Map<String, List<String>> getDatasourceModels() {
return datasourceModels;
}

public Boolean generateEvolutionsScripts() {
public boolean generateEvolutionsScripts() {
return generateEvolutionsScripts;
}

Expand All @@ -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<String, List<String>> datasourceModels = new HashMap<>();

Expand All @@ -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);
}
}

0 comments on commit c9e8a83

Please sign in to comment.