package org.osgl.util;

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

/**
 * A map of (String, {@link ValueObject})
 */
@SuppressWarnings("unused")
public class KVStore extends HashMap<String, ValueObject> implements Map<String, ValueObject> {

    public KVStore() {
    }

    /**
     * Put a simple data into the store with a key. The type of simple data
     * should be allowed by {@link ValueObject}
     * @param key the key
     * @param val the value
     * @return this store instance after the put operation finished
     * @see ValueObject
     */
    public KVStore putValue(String key, Object val) {
        put(key, ValueObject.of(val));
        return this;
    }

    /**
     * Get {@link ValueObject#value() value object value} by key from the
     * store.
     * @param key the key
     * @param <T> the generic type of the return value
     * @return the value stored in the value object associated with the key
     * @see ValueObject#value()
     */
    public <T> T getValue(String key) {
        return get(key).value();
    }

    /**
     * Put a map of (key, value) pair into the store. The value could be any type
     * that supported by {@link ValueObject}
     * @param kvMap a map of {key, value} pair
     * @return the store after put operation finished
     */
    public void putValues(Map<String, Object> kvMap) {
        for (String key : kvMap.keySet()) {
            put(key, ValueObject.of(kvMap.get(key)));
        }
    }

}

@@ -271,26 +271,582 @@
     
-public KVStore() %7B
+/**%0A     * Create an empty %7B@code KVStore%7D%0A     */%0A    public KVStore() %7B%0A    %7D%0A%0A    /**%0A     * Create a %7B@code KVStore%7D by coping another %7B@code KVStore%7D%0A     * @param copy the KVStore in which all (K,V) pairs will be copied into the new KVStore instance%0A     */%0A    public KVStore(KVStore copy) %7B%0A        putAll(copy);%0A    %7D%0A%0A    /**%0A     * Create a %7B@code KVStore%7D with a (String, Object) map%0A     * @param values the map in which all entries will be stored into the new KVStore instance%0A     */%0A    public KVStore(Map%3CString, Object%3E values) %7B%0A        putValues(values);
 %0A   

add copy constructor to KVStore