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

com.slickqa.jupiter.DefaultAttributes Maven / Gradle / Ivy

There is a newer version: 1.0.0-25
Show newest version
package com.slickqa.jupiter;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class DefaultAttributes {
    protected static HashMap attributesCache = null;

    protected static Map EnvironmentVariables = System.getenv();

    public static void wipeCache() {
        attributesCache = null;
    }

    public static HashMap getAttributesFromEnvironment(boolean useCache) {
        if(useCache && attributesCache != null) {
            return new HashMap<>(attributesCache);
        }
        HashMap attrs = new HashMap<>();
        for(String name : System.getProperties().stringPropertyNames()) {
            if(name.startsWith("attr.")) {
                attrs.put(name.substring(5), System.getProperties().getProperty(name));
            }
        }
        for(String name : EnvironmentVariables.keySet()) {
            if(name.startsWith("ATTR_")) {
                attrs.put(name.substring(5), EnvironmentVariables.get(name));
            }
        }
        attributesCache = new HashMap<>(attrs);
        return attrs;
    }

    public static HashMap getAttributesFromEnvironment() {
        return getAttributesFromEnvironment(true);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy