Skip to content

Instantly share code, notes, and snippets.

@snarkbait
Created December 1, 2017 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snarkbait/f9976f912f57e6cd69316dd362dac1e1 to your computer and use it in GitHub Desktop.
Save snarkbait/f9976f912f57e6cd69316dd362dac1e1 to your computer and use it in GitHub Desktop.
Tuple3
package util;
/**
* @author /u/Philboyd_Studge on 3/19/2017.
*/
public class Tuple3<T, U, V> extends Tuple2<T, U> {
private final V v;
public Tuple3(T t, U u, V v) {
super(t, u);
this.v = v;
}
/**
* get third item of tuple
* @return item of type V
*/
public V getThird() {
return v;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Tuple3)) return false;
if (!super.equals(o)) return false;
Tuple3<?, ?, ?> tuple3 = (Tuple3<?, ?, ?>) o;
return v != null ? v.equals(tuple3.v) : tuple3.v == null;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (v != null ? v.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "{ " + super.getFirst() +
", " + super.getSecond() +
", " + v.toString() + " }";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment