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

ai.databand.config.Env Maven / Gradle / Ivy

There is a newer version: 1.0.26.1
Show newest version
package ai.databand.config;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * Environment variables properties source. Vars are passed using uppercase+underscore format:
 * DBND__TRACKING__ENABLED=True
 */
public class Env implements PropertiesSource {

    private final Map props;

    public Env(PropertiesSource parent) {
        Map parentProps = parent.values();
        props = new HashMap<>(parentProps);
        props.putAll(new NormalizedProps(System.getenv()).values());
    }

    public Env() {
        this(new SimpleProps());
    }

    public Map values() {
        return Collections.unmodifiableMap(props);
    }

    @Override
    public Optional getValue(String key) {
        return Optional.ofNullable(props.get(key));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy