Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
Already using Guava, so use its hashCode() method; handle nulls to eq…
Browse files Browse the repository at this point in the history
…uals() and add identity equality shortcut
  • Loading branch information
Steven Scott committed Mar 16, 2011
1 parent d645925 commit fa20066
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lucandra/Pair.java
Expand Up @@ -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;
Expand Down

0 comments on commit fa20066

Please sign in to comment.