/**
* Map构造器
*
*
*/
public final class MapBuilder<K, V> {
private Map<K, V> map;
private MapBuilder() {
map = new HashMap<K, V>();
}
/**
* create a builder
*
* @return
*/
public static <K, V> MapBuilder<K, V> create() {
return new MapBuilder<K, V>();
}
/**
* create a builder
*
* @param kClass key type
* @param vClass value type
*/
public static <K, V> MapBuilder<K, V> forType(Class<K> kClass, Class<V> vClass) {
return new MapBuilder<K, V>();
}
/**
* create a builder and put a kv pair.
*
* @param key
* @param value
* @return
*/
public static <K, V> MapBuilder<K, V> createWith(K key, V value) {
return new MapBuilder<K, V>().with(key, value);
}
/**
* put 键值对
*
* @param key 键
* @param value 值
* @return
*/
public MapBuilder<K, V> with(K key, V value) {
map.put(key, value);
return this;
}