Skip to content

Instantly share code, notes, and snippets.

@anna-is-cute
Created June 20, 2014 15:00
Show Gist options
  • Save anna-is-cute/f515442ff4f6be2108a2 to your computer and use it in GitHub Desktop.
Save anna-is-cute/f515442ff4f6be2108a2 to your computer and use it in GitHub Desktop.
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