Skip to content

sdepold/com.depold.helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

i.creativecommons.org/l/by-sa/3.0/de/88x31.png[http://creativecommons.org/licenses/by-sa/3.0/de/]

com.depold.helpers.MapBuilder

This helper offers a “simple” way to create HashMaps in Java. To do so, just use the following syntax:

Map map = MapBuilder.build( “key1”, 123, “key2”, 345, “key3”, 456 );

And here the “normal” Java code:

Map map = new HashMap<String, Integer>(); map.put(“key1”, 123); map.put(“key2”, 345); map.put(“key3”, 456);

And a “normal” version of an inline definition:

new HashMap<String, Integer>(){{ put(“key1”, 123); put(“key2”, 345); put(“key3”, 456); }}; It’s important, that the passed array has an even length. Otherwise you will get an exception.

Releases

No releases published

Packages

No packages published

Languages