io.atleon.core.ConfigProvider Maven / Gradle / Ivy
package io.atleon.core;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
/**
* Base class of Config-producing resources. Provided Configs are (typically) based solely on the
* contents of the {@code properties} Map wrapped by this Provider.
*
* Config Providers can be named either explicitly or via property introspection. This is useful
* when applying {@link ConfigInterceptor}s. By default, Providers should use the default
* ConfigInterceptors to transform the properties Map prior to generating the final Config. The
* default interceptors allow clients to:
*
* - Override named properties via system and/or environment variables:
*
Override the value of "key" in a ConfigProvider with the name "aws" to "overridden"
*
{@code System.setProperty("atleon.config.aws.key", "overridden")}
* - Randomize properties:
*
Randomize "value" associated with "key" by appending a random UUID
*
{@code configProvider.with("key", "value").with("key.randomize", true)}
*
*
* @param The type of this ConfigProducer
*/
public abstract class ConfigProvider> {
private Map properties = Collections.emptyMap();
private Function