public static R value()

in FlywayLambdaService/src/main/java/com/geekoosh/flyway/request/ValueManager.java [107:120]


    public static <R> R value(R current, EnvironmentVars env, SecretVars secretEnvName, Function<String, R> mapping) throws ResourceNotFoundException, InvalidRequestException, InvalidParameterException {
        SystemEnvironment systemEnvironment = new SystemEnvironment();
        if(current != null) {
            return current;
        } else if(secretEnvName != null && systemEnvironment.getEnv(secretEnvName) != null) {
            String secret = ValueManager.latestSecret(systemEnvironment.getEnv(secretEnvName));
            return mapping != null ? mapping.apply(secret) : (R)secret;

        } else if(env != null && systemEnvironment.getEnv(env) != null) {
            String envValue = systemEnvironment.getEnv(env);
            return mapping != null ? mapping.apply(envValue) : (R)envValue;
        }
        return mapping == null ? null : mapping.apply(null);
    }