Fix PMD violations in hashCode and equals.

Also use the Guava methods for equals and hashCode. Add a test.