Closed GoogleCodeExporter closed 9 years ago
Wait for JDK 7. Its there. Checkout Project Coin.
Yogesh
Original comment by sinhay...@gmail.com
on 8 Sep 2009 at 1:52
The same applies for `newArrayList()` and friends. `newFooMap()` still fits
here, too.
Also, JDK 7 is quite far away. Shifting current production applications (some
of them
don't even use JDK 6) to it might not happen in the next two years or so for
many
projects. Which is where Google Collections comes into play. Which is why I
made this
suggestion.
Original comment by j...@nwsnet.de
on 8 Sep 2009 at 2:26
Look at ImmutableMap and ImmutableSortedMap, which include factory methods and
builders that do what you want. The vararg methods handle up to 5 key-value
pairs,
and the builders can create larger maps.
Your newLinkedHashMap code doesn't support the common case in which the key
type and
value type differ. For that reason, we can't supply a varargs method that
supports
arbitrary sizes.
I'm closing this issue, since the library already has the map factory methods
that
make sense.
Original comment by jared.l....@gmail.com
on 8 Sep 2009 at 5:13
but may I add: very nice example. :) thanks for reminding me of that great book.
Original comment by kevin...@gmail.com
on 8 Sep 2009 at 9:10
jared.l.levy: Indeed, though being immutable is not sufficient in all cases. I
guess
the limit of 5 vararg pairs is somewhat arbitrary (defining additional
overloaded
methods with a greater number however is no actual solution to me, so I don't
request
that)? But I like the Builder interface!
`newLinkedHashMap()` does work using `<String, Object>` as key/value types, but
that
probably uses Object in the end for everything, which isn't really desirable,
but is
sufficient in my case to create comparison data maps for unit testing.
kevinb9n: You're welcome :D
Original comment by j...@nwsnet.de
on 9 Sep 2009 at 8:32
Original issue reported on code.google.com by
j...@nwsnet.de
on 8 Sep 2009 at 10:30