spiffy.core.util
Class HashMapBuilder<K,V>

java.lang.Object
  extended by 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

Constructor Summary
HashMapBuilder()
           
 
Method Summary
 HashMapBuilder<K,V> add(K key, V value)
          add a key-value pair
 HashMap<K,V> build()
          build the hashmap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapBuilder

public HashMapBuilder()
Method Detail

add

public HashMapBuilder<K,V> add(K key,
                               V value)
add a key-value pair


build

public HashMap<K,V> build()
build the hashmap.