This isn't one I've seen much use for.
It would also be possible to write it as a decorating wrapper for a
map, rather than as a static utility method.
Stephen
2009/10/25 assembling signals assembling.sign...@yandex.ru:
Hello!
I am thinking about a new method getSafe(...) for the
Le 26/10/2009 15:56, Paul Benedict a écrit :
Since we're talking Map, I think a more utility would be gained by
including putIfAbsent (see java.util.concurrent) because I see many
lines of code that do that idiom all the time.
This idiom is especially prevalent when the value is itself a nested
I actually don't need closures to accomplish this. Now this solution I
wouldn't recommend for the JDK, but a subclass of Map could
automatically do the management of the inner collections for me.
Paul
Hi Paul,
Paul Benedict wrote:
Since we're talking Map, I think a more utility would be gained by
including putIfAbsent (see java.util.concurrent) because I see many
lines of code that do that idiom all the time.
This idiom is especially prevalent when the value is itself a nested collection.
Hello!
I am thinking about a new method getSafe(...) for the Collections utility
class.
It would do get(...) on a map, but instead of returning null (when an entry is
not found),
it would throw NoSuchElementException.
@Nonnull
public static K,V V getSafe(MapK,V map, Object key){