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

shoehorn.Shoehorn Maven / Gradle / Ivy

package shoehorn;

import java.util.Map;

/**
 * @author Ryan Brainard
 */
public class Shoehorn {

    @SuppressWarnings("UnusedDeclaration")
    public static void premain(String agentArgs) {
        new Shoehorn(System.getenv(), new MappingLoader().load(System.getenv())).shoehorn();
    }

    private final Map environment;
    private final Map mappings;

    public Shoehorn(Map environment, Map mappings) {
        this.environment = environment;
        this.mappings = mappings;
    }

    void shoehorn() {
        for (Map.Entry map : mappings.entrySet()) {
            final String propName = map.getKey();
            final String envName = map.getValue();

            if (!environment.containsKey(envName)) {
                continue;
            }

            System.setProperty(propName, environment.get(envName));
            System.out.println("Shoehorned [" + envName + "] into [" + propName + "]");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy