You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original issue created by stephen.kestle on 2010-02-08 at 01:21 AM
One of my favourites from commons-collections is sorely lacking from google
collections: the ability to decorate an underlying map with a function to
be able to guarantee a not null return for map.get().
LazyMap.get(Object key) is described as follows:
public Object get(Object key) {
// create value for key if key is not currently in the map
if (map.containsKey(key) == false) {
Object value = factory.transform(key);
map.put(key, value);
return value;
}
return map.get(key);
}
This would be utterly awesome to be able to do in google-collections (in a
type safe way!)
Note that this is not necessarily a case for multimaps - the lazy map can
be used for any grouped function - summary operations etc; e.g. not just
the obvious lazymap.get(myKey).add(anotherValue)
The text was updated successfully, but these errors were encountered:
Thank you for updating that!
One of the things I love about SO is that the more we use it, the more it
automatically "becomes" our FAQ, without extra separate labor required.
Original issue created by stephen.kestle on 2010-02-08 at 01:21 AM
One of my favourites from commons-collections is sorely lacking from google
collections: the ability to decorate an underlying map with a function to
be able to guarantee a not null return for map.get().
LazyMap.get(Object key) is described as follows:
This would be utterly awesome to be able to do in google-collections (in a
type safe way!)
Note that this is not necessarily a case for multimaps - the lazy map can
be used for any grouped function - summary operations etc; e.g. not just
the obvious lazymap.get(myKey).add(anotherValue)
The text was updated successfully, but these errors were encountered: