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

org.noos.xing.mydoggy.plaf.common.context.DefaultMutableContext Maven / Gradle / Ivy

The newest version!
package org.noos.xing.mydoggy.plaf.common.context;

import org.noos.common.context.MutableContext;

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

/**
 * @author Angelo De Caro ([email protected])
 */
public class DefaultMutableContext implements MutableContext {
    protected Map map;

    public DefaultMutableContext() {
        this.map = new HashMap();
    }

    public DefaultMutableContext(Object... entries) {
        this();
        if (entries.length % 2 == 0) {
            for (int i = 0; i < entries.length; i += 2) {
                map.put(entries[i], entries[i + 1]);
            }
        } else
            throw new IllegalArgumentException("Invalid number of arguments. It must be even");

    }

    public void put(Object key, Object value) {
        map.put(key, value);
    }

    public Object remove(Object key) {
        return map.remove(key);
    }

    public Object get(Object key) {
        return map.get(key);
    }

    public  T get(Class key) {
        return (T) map.get(key);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy