Guava Vs Apache Commons Hash/Equals builders
I'd call this difference "existence". There are EqualsBuilder
and HashCodeBuilder
in Apache Commons and there are no builders in Guava. All you get from Guava is a utility class MoreObjects
(renamed from Objects
as there's such a class in JDK now).
The advantages of Guava's approach come from the non-existence of the builder:
- it produces no garbage
- it's faster
The JIT compiler can possibly eliminate the garbage via Escape Analysis and also the associated overhead. Then they get equally fast as they do exactly the same.
I personally find the builders slightly more readable. If you find not using them better, then Guava is surely the right thing for you. As you can see, the static methods are good enough for the task.
Note also that there's also a ComparisonChain which is a sort of Comparable-builder.