«« Next » « Previous
«« Next » « Previous

Link Details

Give a link some love! Login and vote now.
Link 66333 thumbnail

By arikthered
via coderoshi.com
Published: Feb 14 2008 / 22:53

Don't you hate doing that if-null-then-populate-value-thing every time you want to generate a Map (usually of Collections)? Turn that 5-line sludge into 1-line elegance - and feel safe doing it! Believe me: this is cool.
  • 12
  • 4
  • 1954
  • 914

Comments

Add your comment
User 171944 avatar

b0b0b0b replied ago:

0 votes Vote down Vote up Reply

clone + reflection = blech

User 204894 avatar

arikthered replied ago:

1 votes Vote down Vote up Reply

So you must also hate Spring, Guice, Eclipse and Maven - that's how they work, buddy.

User 171944 avatar

b0b0b0b replied ago:

0 votes Vote down Vote up Reply

Actually yes I do.

User 200744 avatar

johannz replied ago:

1 votes Vote down Vote up Reply

This is similar to existing code in Jakarta Commons Collections. Specifically, the LazyMap and the MultiValueMap classes. The only difference is his version is generic compatible.

Google Collections (http://code.google.com/p/google-collections/) offers a Generics-enabled multimap already.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.