package me.andrz.builder.map;

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

/**
 *
 * http://docs.guava-libraries.googlecode.com/git/javadoc/src-html/com/google/common/collect/ImmutableMap.Builder.html#line.217
 */
public class MapBuilder<K,V> {

    private Map<K, V> map;

    public MapBuilder() {
        this.map = new HashMap<K, V>();
    }

    @SuppressWarnings("unchecked")
    public MapBuilder(Class<? extends Map> c) throws IllegalAccessException, InstantiationException {
        this.map = c.newInstance();
    }

    public MapBuilder(Map<K,V> m) {
        this.map = m;
    }

    public MapBuilder<K,V> put(K k, V v) {
        map.put(k, v);
        return this;
    }

    public MapBuilder<K,V> p(K k, V v) {
        return put(k, v);
    }

    public MapBuilder<K,V> put(Map.Entry<? extends K, ? extends V>e) {
        return put(e.getKey(), e.getValue());
    }

    public MapBuilder<K,V> p(Map.Entry<? extends K, ? extends V> e) {
        return put(e);
    }

    public MapBuilder<K,V> putAll(Map<? extends K, ? extends V> m) {
        map.putAll(m);
        return this;
    }

    public MapBuilder<K,V> pa(Map<? extends K, ? extends V> m) {
        return putAll(m);
    }

    public MapBuilder<K,V> remove(K k) {
        map.remove(k);
        return this;
    }

    public MapBuilder<K,V> r(K k) {
        return remove(k);
    }

    public MapBuilder<K,V> remove(K k, V v) {
        map.remove(k, v);
        return this;
    }

    public MapBuilder<K,V> r(K k, V v) {
        return remove(k, v);
    }

    public MapBuilder<K,V> remove(Map.Entry<? extends K, ? extends V>e) {
        return remove(e.getKey(), e.getValue());
    }

    public MapBuilder<K,V> r(Map.Entry<? extends K, ? extends V> e) {
        return remove(e);
    }

    public Map<K,V> build() {
        return map;
    }
}

@@ -1365,185 +1365,8 @@
  %7D%0A%0A
-    public MapBuilder%3CK,V%3E remove(K k, V v) %7B%0A        map.remove(k, v);%0A        return this;%0A    %7D%0A%0A    public MapBuilder%3CK,V%3E r(K k, V v) %7B%0A        return remove(k, v);%0A    %7D%0A%0A
     
@@ -1463,38 +1463,24 @@
 e(e.getKey()
-, e.getValue()
 );%0A    %7D%0A%0A  

Remove methods to remove with value.