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

jdbi_modules.Store Maven / Gradle / Ivy

package jdbi_modules;

import java.util.Map;

/**
 * @since 14.04.2018
 */
public interface Store {
    /**
     * @param storeMap the map to create the store of
     * @return the created store
     */
    static Store of(final Map, Object> storeMap) {
        return new Store() {
            @Override
            @SuppressWarnings("unchecked")
            public  B require(final Class key) {
                return (B) storeMap.get(key);
            }

            @Override
            public  void place(final Class key, final B value) {
                storeMap.put(key, value);
            }
        };
    }

    /**
     * @param key the type of object to access from the store
     * @param  the type accessed
     * @return the object found
     */
     B require(Class key);

    /**
     * @param key   the type of object to access from the store
     * @param value the value to store
     * @param    the type of the object
     */
     void place(Class key, B value);
}