Java Devs: Apache Collections Utils 4 or Google Guava?

Status
Not open for further replies.

gregatron5

Ars Legatus Legionis
13,003
Subscriptor++
I'm working with a code base that currently uses both collections4 and guava (and some LambdaJ), and I'm thinking of making a strong push towards eliminating one or the other. A bunch of stuff I've seen online says that Guava is better since it supports generics, but those are all old and I've found nothing of substance that's more recent.

Anyone have any thoughts?

If it matters, for now we're stuck with Java 7.
 

Jonathon

Ars Legatus Legionis
17,644
Subscriptor
Apache Collections supports generics, so that's not a reason to choose one over the other.

If the collections you need are available in it, I'd probably lean towards Guava, though. That's mostly because I haven't actually used Apache Collections before (and have used Guava), but, on the collections side of things, Guava provides immutable collections and Apache Collections doesn't (AFAICT). That's especially useful if you're exposing any kind of a public API.
 

gregatron5

Ars Legatus Legionis
13,003
Subscriptor++
Yeah, I spent a lot of time at a WebObjects position and then did some Obj-C Cocoa stuff. Coming back to regular Java after that made me realize just how much immutable collections are the Right Thing to default to. I hate when people write code like someObject.getSomeCollection().add(someValue);. It's impossible to find all the places where values are added in code like that. My next project I'm going to enforce Guava immutable collections in collection return methods everywhere.
 
Status
Not open for further replies.