Skip to content
JavaHelpers
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.settings
bin
src/com/depold/helpers
test/com/depold/helpers
.classpath
.project
README.rdoc

README.rdoc

License

href=“http://i.creativecommons.org/l/by-sa/3.0/de/88x31.png[http://creativecommons.org/licenses/by-sa/3.0/de/]”>i.creativecommons.org/l/by-sa/3.0/de/88x31.png

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.

You can’t perform that action at this time.