I wonder what is the most useful class in the Google collections framework?
In my experience, Iterables
and Lists
.
I use Lists.newArrayList
frequently (usually as a static import) and Iterables
is the closest that Java gets to LINQ...
Oh, and not particularly collection-y, but Preconditions.checkNotNull
is very handy too, again with a static import:
public MyClass (String name, ...)
{
this.name = checkNotNull(name);
// etc
}
Then there's all the immutability stuff, multi-maps, MapMaker
etc... It's just a great library. KevinB et al rock :)
I have used Multimap a lot.
I cursed then a little bit when new ArrayListMultimap() was not working, but then after googling a lot I figured out that they were using ArrayListMultimap.create(), which is cleaner as you don't need to specify the map types twice (as recommended in the Effective Java book, which the author as far as I know is the chief Java dude at google).
Nice thing about Multimap is that, among the several implementations of it, there was one where the list behaves as a set (no duplicated elements, actually, it's no duplicated key + value elements), that really helped.
I think it's a great library and I am moving into using more and more often instead of the commons collection.
Inside Google, the answer is com.google.common.collect.Lists.