Permalink
Browse files

Already using Guava, so use its hashCode() method; handle nulls to eq…

…uals() and add identity equality shortcut
  • Loading branch information...
1 parent d645925 commit fa20066fa5c95508110d19721f6019bb01518d1f Steven Scott committed Mar 16, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/lucandra/Pair.java
View
@@ -16,13 +16,16 @@ public Pair(T1 left, T2 right)
@Override
public final int hashCode()
{
- int hashCode = 31 + (left == null ? 0 : left.hashCode());
- return 31*hashCode + (right == null ? 0 : right.hashCode());
+ return Objects.hashCode(left, right);
}
@Override
public final boolean equals(Object o)
{
+ if (o == null)
+ return false;
+ if (this == o)
+ return true;
if(!(o instanceof Pair))
return false;
Pair that = (Pair)o;

0 comments on commit fa20066

Please sign in to comment.