Code-Optimierungen

This commit is contained in:
2026-04-13 07:21:31 +02:00
parent f0538fa247
commit 59f13608cc
3 changed files with 16 additions and 15 deletions
@@ -307,13 +307,13 @@ public class StartConfigurationValidator {
* or exists and is a directory.
*/
private void validateOptionalExistingDirectory(Path directoryPath, String fieldName, List<String> errors) {
if (directoryPath != null && !directoryPath.toString().isBlank() && Files.exists(directoryPath)) {
if (!Files.isDirectory(directoryPath)) {
errors.add("- " + fieldName + ": exists but is not a directory: " + directoryPath);
}
}
// If it doesn't exist yet, that's acceptable - we don't auto-create
if (directoryPath != null
&& !directoryPath.toString().isBlank()
&& Files.exists(directoryPath)
&& !Files.isDirectory(directoryPath)) {
errors.add("- " + fieldName + ": exists but is not a directory: " + directoryPath);
}
// If it doesn't exist yet, that's acceptable - we don't auto-create
}
/**
@@ -8,6 +8,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import de.gecheckt.pdf.umbenenner.application.config.provider.MultiProviderConfiguration;
import de.gecheckt.pdf.umbenenner.application.config.startup.StartConfiguration;
@@ -45,7 +46,7 @@ public class PropertiesConfigurationPortAdapter implements ConfigurationPort {
*
* @param environmentLookup a function that looks up environment variables by name
*/
public PropertiesConfigurationPortAdapter(Function<String, String> environmentLookup) {
public PropertiesConfigurationPortAdapter(UnaryOperator<String> environmentLookup) {
this(environmentLookup, Paths.get(DEFAULT_CONFIG_FILE_PATH));
}
@@ -69,7 +70,7 @@ public class PropertiesConfigurationPortAdapter implements ConfigurationPort {
* @param environmentLookup a function that looks up environment variables by name
* @param configFilePath the path to the configuration properties file
*/
public PropertiesConfigurationPortAdapter(Function<String, String> environmentLookup, Path configFilePath) {
public PropertiesConfigurationPortAdapter(UnaryOperator<String> environmentLookup, Path configFilePath) {
this.environmentLookup = environmentLookup;
this.configFilePath = configFilePath;
}