Created
June 20, 2014 15:00
-
-
Save anna-is-cute/f515442ff4f6be2108a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class Pair<T, U> { | |
private final T first; | |
private final U second; | |
private Pair(T first, U second) { | |
this.first = first; | |
this.second = second; | |
} | |
public T getFirst() { | |
return this.first; | |
} | |
public U getSecond() { | |
return this.second; | |
} | |
@Override | |
public String toString() { | |
return String.format("Pair<%s, %s>", this.getFirst().toString(), this.getSecond().toString()); | |
} | |
@Override | |
public boolean equals(Object o) { | |
if (o == this) return true; | |
if (!(o instanceof Pair)) return false; | |
final Pair<?, ?> other = (Pair<?, ?>) o; | |
return !(!this.getFirst().equals(other.getFirst()) || !this.getSecond().equals(other.getSecond())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment