spiffy.core.util
Class HashMapBuilder<K,V>
java.lang.Object
spiffy.core.util.HashMapBuilder<K,V>
public class HashMapBuilder<K,V>
- extends Object
Shortcut way to build hashmaps. It's great for making concise tests.
Instead of
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("one", 1);
map.put("two", 2);
...
you can now chain the inserts and use the more familiar add().
HashMap<String, Integer> map = new HashMapBuilder<String, Integer>().add("one", 1).add("two", 2).build();
- Author:
- Kasper B. Graversen, (c) 2007-2008
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HashMapBuilder
public HashMapBuilder()
add
public HashMapBuilder<K,V> add(K key,
V value)
- add a key-value pair
build
public HashMap<K,V> build()
- build the hashmap.