org.jboss.portal.common.util
Class MapBuilder<M extends java.util.Map<K,V>,K,V>

java.lang.Object
  extended by org.jboss.portal.common.util.MapBuilder<M,K,V>

public class MapBuilder<M extends java.util.Map<K,V>,K,V>
extends java.lang.Object

An helper to build map in a simple manner.

Version:
$Revision: 7228 $
Author:
Julien Viet

Method Summary
static
<M extends java.util.Map<K,V>,K,V>
MapBuilder<M,K,V>
create(M m)
           
 M get()
           
static
<K,V> MapBuilder<java.util.HashMap<K,V>,K,V>
hashMap()
          Creates a new instance.
static
<K,V> MapBuilder<java.util.HashMap<K,V>,K,V>
hashMap(K k, V v)
          Creates a new instance.
static
<K,V> MapBuilder<java.util.LinkedHashMap<K,V>,K,V>
linkedHashMap()
          Creates a new instance.
static
<K,V> MapBuilder<java.util.LinkedHashMap<K,V>,K,V>
linkedHashMap(K k, V v)
          Creates a new instance.
 MapBuilder<M,K,V> put(K key, V value)
          Add the object to the collection.
 MapBuilder<M,K,V> putAll(M all)
          Add all the objects to the collection.
static
<K,V> MapBuilder<java.util.TreeMap<K,V>,K,V>
treeMap()
          Creates a new instance.
static
<K,V> MapBuilder<java.util.TreeMap<K,V>,K,V>
treeMap(K k, V v)
          Creates a new instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hashMap

public static <K,V> MapBuilder<java.util.HashMap<K,V>,K,V> hashMap()
Creates a new instance.

Returns:
a new instance

hashMap

public static <K,V> MapBuilder<java.util.HashMap<K,V>,K,V> hashMap(K k,
                                                                   V v)
Creates a new instance.

Returns:
a new instance

treeMap

public static <K,V> MapBuilder<java.util.TreeMap<K,V>,K,V> treeMap()
Creates a new instance.

Returns:
a new instance

treeMap

public static <K,V> MapBuilder<java.util.TreeMap<K,V>,K,V> treeMap(K k,
                                                                   V v)
Creates a new instance.

Returns:
a new instance

linkedHashMap

public static <K,V> MapBuilder<java.util.LinkedHashMap<K,V>,K,V> linkedHashMap()
Creates a new instance.

Returns:
a new instance

linkedHashMap

public static <K,V> MapBuilder<java.util.LinkedHashMap<K,V>,K,V> linkedHashMap(K k,
                                                                               V v)
Creates a new instance.

Returns:
a new instance

create

public static <M extends java.util.Map<K,V>,K,V> MapBuilder<M,K,V> create(M m)

put

public MapBuilder<M,K,V> put(K key,
                             V value)
Add the object to the collection.

Parameters:
key - the key
value - the value
Returns:
the builder

putAll

public MapBuilder<M,K,V> putAll(M all)
Add all the objects to the collection.

Parameters:
all - the entries to add
Returns:
the builder

get

public M get()