package de.retest.recheck.configuration;

import java.nio.file.Path;

public class ProjectConfigurationUtil {

	private ProjectConfigurationUtil() {

	}

	public static Path findProjectConfigurationFolder() {
		return ProjectRootFinderUtil.getProjectRoot()
				.orElseThrow( () -> new RuntimeException( "Project root could not be found." ) )
				.resolve( ProjectConfiguration.RETEST_PROJECT_CONFIG_FOLDER );
	}

	public static Path findProjectConfigurationFolder( final Path path ) {
		return ProjectRootFinderUtil.getProjectRoot( path )
				.orElseThrow( () -> new RuntimeException( "Project root could not be found." ) )
				.resolve( ProjectConfiguration.RETEST_PROJECT_CONFIG_FOLDER );
	}

	public static Path findProjectConfiguration() {
		return findProjectConfigurationFolder().resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES );
	}

	public static Path findProjectConfiguration( final Path path ) {
		return findProjectConfigurationFolder( path ).resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES );
	}

}

@@ -61,16 +61,43 @@
 le.Path;
+%0Aimport java.util.Optional;
 %0A%0Apublic
@@ -181,36 +181,46 @@
 %0A%09public static 
+Optional%3C
 Path
+%3E
  findProjectConf
@@ -232,27 +232,64 @@
 tion
-Folder
 () %7B%0A%09%09
-return
+final Optional%3CPath%3E projectConfigurationFolder =
  Pro
@@ -327,159 +327,208 @@
 ot()
+;
 %0A%09%09
-%09%09.orElseThrow( () -%3E new RuntimeException( %22Project root could not be found.%22 ) )%0A%09%09%09%09.resolve( ProjectConfiguration.RETEST_PROJECT_CONFIG_FOLDER )
+return projectConfigurationFolder.isPresent()%0A%09%09%09%09? projectConfigurationFolder%0A%09%09%09%09%09%09.map( path -%3E path.resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES ) )%0A%09%09%09%09: projectConfigurationFolder
 ;%0A%09%7D
@@ -536,36 +536,46 @@
 %0A%09public static 
+Optional%3C
 Path
+%3E
  findProjectConf
@@ -583,22 +583,16 @@
 guration
-Folder
 ( final 
@@ -607,22 +607,65 @@
 h ) %7B%0A%09%09
-return
+final Optional%3CPath%3E projectConfigurationFolder =
  Project
@@ -705,490 +705,210 @@
 th )
+;
 %0A%09%09
-%09%09.orElseThrow( () -%3E new RuntimeException( %22Project root could not be found.%22 ) )%0A%09%09%09%09.resolve( ProjectConfiguration.RETEST_PROJECT_CONFIG_FOLDER );%0A%09%7D%0A%0A%09public static Path findProjectConfiguration() %7B%0A%09%09return findProjectConfigurationFolder().resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES );%0A%09%7D%0A%0A%09public static Path findProjectConfiguration( final Path path ) %7B%0A%09%09return findProjectConfigurationFolder( path ).resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES )
+return projectConfigurationFolder.isPresent()%0A%09%09%09%09? projectConfigurationFolder%0A%09%09%09%09%09%09.map( path1 -%3E path1.resolve( ProjectConfiguration.RETEST_PROJECT_PROPERTIES ) )%0A%09%09%09%09: projectConfigurationFolder
 ;%0A%09%7D

Return optional instead of handling it