org.omnaest.utils.structure.map
Class MapBuilder

java.lang.Object
  extended by org.omnaest.utils.structure.map.MapBuilder

public class MapBuilder
extends Object

Builder for Map instances filled with keys and values.

The MapBuilder is not thread safe, since it uses an temporary not thread safe internal Map.
The order of elements is respected when put into the result Map, so a Map implementation which supports ordering will contain the Map.Entrys in the right order afterwards.

Example:

 Map<String, String> map = MapUtils.builder()
                                   .put( "key1", "value1" )
                                   .put( "key2", "value2" )
                                   .put( "key3", "value3" )
                                   .buildAs()
                                   .linkedHashMap();
 

Author:
Omnaest
See Also:
Map, SortedMap

Nested Class Summary
static interface MapBuilder.ClosedMapComposer<K,V>
          A MapBuilder.ClosedMapComposer allows to create specific Map instances containing the key value pairs defined with the MapBuilder.MapComposer
static interface MapBuilder.MapComposer<K,V>
          A MapBuilder.MapComposer allows to compose a Map by adding key value pairs.
static interface MapBuilder.MapFactory<M extends Map<K,V>,K,V>
          Factory for a Map instance
static interface MapBuilder.MapRootComposer
          See MapBuilder.MapComposer
 
Constructor Summary
MapBuilder()
           
 
Method Summary
<K,V> MapBuilder.MapComposer<K,V>
put(K key, V value)
           
<K,V> MapBuilder.MapComposer<K,V>
putAll(Map<? extends K,? extends V> map)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapBuilder

public MapBuilder()
See Also:
MapBuilder
Method Detail

put

public <K,V> MapBuilder.MapComposer<K,V> put(K key,
                                             V value)
Parameters:
key -
value -
Returns:
MapBuilder.MapComposer instance
See Also:
MapBuilder.MapComposer.put(Object, Object)

putAll

public <K,V> MapBuilder.MapComposer<K,V> putAll(Map<? extends K,? extends V> map)
Parameters:
map -
Returns:
MapBuilder.MapComposer instance
See Also:
MapBuilder.MapComposer.putAll(Map)


Copyright © 2013. All Rights Reserved.