Skip to content

Commit

Permalink
Elegant way of return value in fromPlatformConfig method
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Dupuy <66690739+flo-dup@users.noreply.github.com>
Signed-off-by: BAUDRIER Dimitri <dimitri.baudrier@rte-france.com>
  • Loading branch information
2 people authored and BAUDRIER Dimitri committed Nov 24, 2022
1 parent a8bfd8e commit e91bb63
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ public static DynaFlowConfig fromPropertyFile() {

public static DynaFlowConfig fromPlatformConfig(PlatformConfig platformConfig) {
Objects.requireNonNull(platformConfig);
Optional<ModuleConfig> optionalModuleConfig = platformConfig.getOptionalModuleConfig("dynaflow");
if (optionalModuleConfig.isPresent()) {
Path homeDir = optionalModuleConfig.get().getPathProperty("homeDir");
boolean debug = optionalModuleConfig.get().getBooleanProperty("debug", DEFAULT_DEBUG);
return new DynaFlowConfig(homeDir, debug);
}
return null;
return platformConfig.getOptionalModuleConfig("dynaflow")
.map(config -> new DynaFlowConfig(config.getPathProperty("homeDir"), config.getBooleanProperty("debug", DEFAULT_DEBUG)))
.orElse(null);
}

public Map<String, String> createEnv() {
Expand Down

0 comments on commit e91bb63

Please sign in to comment.