-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 All,
I have a need for the following Map implementation: Given 2 (or more) source Maps, iteratively fetch the value for a key from each of the composed Maps, returning the first non-null value (or, at if you prefer, the first value for which the key is set). This is intended to work essentially as a Map which can override some default values (from a shared Map). I first tried to use CompositeMap, since it looked like exactly what I was looking for. I ended up with an IllegalArgumentException since some keys are defined in both Maps. IMO, the class documentation doesn't make it clear that the keys most be unique across the source Maps (though the documentation for the 2-Map constructor does an exception can be thrown if there is a "key collision"). Next I looked at DefaultedMap, but that provides a single default value for undefined keys on a single Map. I poked-around the javadoc but couldn't find anything that looked like it fit my needs. Am I missing something? Am I looking for something that is so trivial that nobody has bothered writing it? Yes, I could simply do this: Map composedMap = new HashMap(); composedMap.addAll(defaultValuesMap); composedMap.addAll(overriddenValuesMap); ... but what fun is that? Thanks, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqCIn0ACgkQ9CaO5/Lv0PDcJwCdEuvCDXKSnDlwxhmRPJvIQ1F7 /NAAnR5F7suSDzeo+/bk8616TfagkAp4 =GS99 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org