All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sitture.envconfig.EnvConfigUtils Maven / Gradle / Ivy

Go to download

A simple utility to manage environment configs in Java-based projects by merging *.properties files with environment variables overrides.

There is a newer version: 1.13.1
Show newest version
package com.github.sitture.envconfig;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

final class EnvConfigUtils {

    public static final String CONFIG_PATH_DEFAULT = "config";
    public static final String CONFIG_ENV_DEFAULT = "default";
    public static final String CONFIG_DELIMITER_DEFAULT = ",";

    private EnvConfigUtils() {
    }

    static String getProcessedPropertyKey(final String envVar) {
        return envVar.replaceAll("_", ".").toLowerCase();
    }

    static String getProcessedEnvKey(final String property) {
        return property.replaceAll("\\.", "_").toUpperCase();
    }

    static List getListOfValues(final String value, final String delimiter) {
        return null == value
            ? Collections.emptyList()
            : Stream.of(value.split(delimiter))
            .map(String::trim)
            .collect(Collectors.toList());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy