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

com.github.ajoecker.gauge.random.data.VariableStorage Maven / Gradle / Ivy

There is a newer version: 0.2.2
Show newest version
package com.github.ajoecker.gauge.random.data;

import static com.thoughtworks.gauge.datastore.DataStoreFactory.*;

public interface VariableStorage {
    void put(String key, Object value);
    Object get(String key);

    static VariableStorage create() {
        String clearStateLevel = System.getenv("gauge_clear_state_level");
        if ("suite".equals(clearStateLevel)) {
            return new VariableStorage() {
                @Override
                public void put(String key, Object value) {
                    getSuiteDataStore().put(key, value);
                }

                @Override
                public Object get(String key) {
                    return getSuiteDataStore().get(key);
                }
            };
        } else if ("spec".equals(clearStateLevel)) {
            return new VariableStorage() {
                @Override
                public void put(String key, Object value) {
                    getSpecDataStore().put(key, value);
                }

                @Override
                public Object get(String key) {
                    return getSpecDataStore().get(key);
                }
            };
        }
        return new VariableStorage() {
            @Override
            public void put(String key, Object value) {
                getScenarioDataStore().put(key, value);
            }

            @Override
            public Object get(String key) {
                return getScenarioDataStore().get(key);
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy