DEV Community

iron_man
iron_man

Posted on

Edit

package com.hardening;

import java.nio.file.Path;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("hardening")
public record Settings(
String mode,
Path tnsPath,
List segments,
Path libraryPath,
Path historyPath,
boolean allowWrites,
String credentialStrategy,
String adminPassword,
String userPassword
) {
public Settings {
mode = mode == null ? "demo" : mode.trim().toLowerCase();

    if (!mode.equals("demo") && !mode.equals("oracle")) {
        throw new IllegalArgumentException("Unknown mode: " + mode);
    }

    segments = segments == null ? List.of() : List.copyOf(segments);

    credentialStrategy =
            credentialStrategy == null || credentialStrategy.isBlank()
                    ? "runtime"
                    : credentialStrategy.trim().toLowerCase();
}

public boolean demo() {
    return mode.equals("demo");
}

@Override
public String toString() {
    return "Settings{mode='" + mode + "'}";
}
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)