// Path: cfg4j-core/src/main/java/org/cfg4j/source/ConfigurationSource.java
// public interface ConfigurationSource {
// 
//   /**
//    * Get configuration set for a given {@code environment} from this source in a form of {@link Properties}.
//    * Provided {@link Environment} will be used to determine which environment to use.
//    *
//    * @param environment environment to use
//    * @return configuration set for {@code environment}
//    * @throws MissingEnvironmentException when requested environment couldn't be found
//    * @throws IllegalStateException       when unable to fetch configuration
//    */
//   Properties getConfiguration(Environment environment);
// 
//   /**
//    * Initialize this source. This method has to be called before any other method of this instance.
//    *
//    * @throws IllegalStateException        when source was improperly configured
//    * @throws SourceCommunicationException when unable to communicate with source
//    */
//   void init();
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/Environment.java
// public interface Environment {
// 
//   /**
//    * Name of the environment. Should not be null.
//    *
//    * @return environment name. Not null.
//    */
//   String getName();
// 
// }


import org.cfg4j.source.ConfigurationSource;
import org.cfg4j.source.context.environment.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

  @Override
  public void init() {
    LOG.debug("Initializing: Environment Variable Configuration Source");
    initialized = true;
  }

  @Override
  public String toString() {
    return "EnvironmentVariablesConfigurationSource{}";
  }

  /**
   * Convert the Environment Variable Name to the expected Properties Key formatting
   *
   * @param environmentVariableKey The Env Variable Name, possibly prefixed with the {@link Environment} which
   *                               in this context serves as a way to namespace variables
   * @param environmentContext     The Environment context in format: ENVIRONMENTNAME_
   * @return A {@link String} with the environment prefix removed and all underscores converted to periods
   */
  private static String convertToPropertiesKey(String environmentVariableKey, String environmentContext) {
    return environmentVariableKey.substring(environmentContext.length()).replace(ENV_DELIMITER, PROPERTIES_DELIMITER);
  }

  /**
   * Format the provided {@link Environment} to ensure it ends with an underscore
   *
   * @param environment The provided {@link Environment} context
   * @return The formatted {@link String} of the {@link Environment} context
   */
// Path: cfg4j-core/src/main/java/org/cfg4j/source/ConfigurationSource.java
// public interface ConfigurationSource {
// 
//   /**
//    * Get configuration set for a given {@code environment} from this source in a form of {@link Properties}.
//    * Provided {@link Environment} will be used to determine which environment to use.
//    *
//    * @param environment environment to use
//    * @return configuration set for {@code environment}
//    * @throws MissingEnvironmentException when requested environment couldn't be found
//    * @throws IllegalStateException       when unable to fetch configuration
//    */
//   Properties getConfiguration(Environment environment);
// 
//   /**
//    * Initialize this source. This method has to be called before any other method of this instance.
//    *
//    * @throws IllegalStateException        when source was improperly configured
//    * @throws SourceCommunicationException when unable to communicate with source
//    */
//   void init();
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/Environment.java
// public interface Environment {
// 
//   /**
//    * Name of the environment. Should not be null.
//    *
//    * @return environment name. Not null.
//    */
//   String getName();
// 
// }


// Path: cfg4j-core/src/main/java/org/cfg4j/source/system/EnvironmentVariablesConfigurationSource.java
import org.cfg4j.source.ConfigurationSource;
import org.cfg4j.source.context.environment.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;


  @Override
  public void init() {
    LOG.debug("Initializing: Environment Variable Configuration Source");
    initialized = true;
  }

  @Override
  public String toString() {
    return "EnvironmentVariablesConfigurationSource{}";
  }

  /**
   * Convert the Environment Variable Name to the expected Properties Key formatting
   *
   * @param environmentVariableKey The Env Variable Name, possibly prefixed with the {@link Environment} which
   *                               in this context serves as a way to namespace variables
   * @param environmentContext     The Environment context in format: ENVIRONMENTNAME_
   * @return A {@link String} with the environment prefix removed and all underscores converted to periods
   */
  private static String convertToPropertiesKey(String environmentVariableKey, String environmentContext) {
    return environmentVariableKey.substring(environmentContext.length()).replace(ENV_DELIMITER, PROPERTIES_DELIMITER);
  }

  /**
   * Format the provided {@link Environment} to ensure it ends with an underscore
   *
   * @param environment The provided {@link Environment} context
   * @return The formatted {@link String} of the {@link Environment} context
   */
  private static String formatEnvironmentContext(Environment environment) {