RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Comparing the Google Collections Library with the Apache Commons Collections : Page 4

Like Apache's Jakarta Commons Collections, the recently released Google Collections Library also enhances the Java Collections Framework but offers some unique enhancements you may prefer.

What's Missing in Google Collections Library?
I found no equivalents for the following Commons Collections classes in the Library:
  • org.apache.commons.collections.keyvalue.MultiKey – This class allows you to use multiple attributes to create a key for use in a Map.
  • org.apache.commons.collections.buffer – This class defines a contract for object removal in a collection. According to the JavaDoc of the Buffer interface, "The removal order can be based on insertion order (for example, a FIFO queue or a LIFO stack), on access order (e.g., an LRU cache), on some arbitrary comparator (e.g., a priority queue) or on any other well-defined ordering."
  • org.apache.commons.collections.functors – This class doesn't have the Closure feature, to be called if the Predicate evaluate method returns true. But Predicate support is available in Google library to be used with collections for find or filter operations.

I also did not find equivalents for FixedSizeList, LazyList, and a few other specific list types in the com.google.common.collect package, FixedSizeMap, Flat3Map, LazyMap, LRUMap, and ListOrderedSet.

More Choice for the Commons Collections User
Although Google already actively uses the Library in applications such as GMail, Google Reader, and Blogger, the developers have kept the current API release (0.5) as Alpha because an official release would require backward compatibility. Keeping it an Alpha allows them the freedom to make changes. Still, the API achieves about 85 percent functional test coverage according to the Google Collections Library FAQ.

Now you know how the Google Collections Library compares with Apache Commons Collections. If you are not a fan of using JDK 5 Generics, Commons Collections probably will meet your needs. Personally, I like how few classes and packages are in Google's implementation, which makes it very easy to learn and use in a project right away. If the Commons Collections community revamps its offering as a result of the Library release, it will be interesting to observe which one makes it into the JDK in the future.

Narayanan A.R. is a passionate advocate of test-driven development, agile methodologies, Java technology, and design patterns. He has several years of experience in software design and development using Java technologies.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date