package swensen.functional;
/**
* A generic immutable tuple.
* @author Stephen Swensen
* @param <T1>
* @param <T2>
* @param <T3>
* @param <T4>
* @param <T5>
* @param <T6>
*/
public class Tuple6<T1,T2,T3,T4,T5,T6> {
public final T1 t1;
public final T2 t2;
public final T3 t3;
public final T4 t4;
public final T5 t5;
public final T6 t6;
public Tuple6(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
this.t1 = t1;
this.t2 = t2;
this.t3 = t3;
this.t4 = t4;
this.t5 = t5;
this.t6 = t6;
}
public static <T1,T2,T3,T4,T5,T6> Tuple6<T1,T2,T3,T4,T5,T6> create(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
return new Tuple6<T1,T2,T3,T4,T5,T6>(t1,t2,t3,t4,t5,t6);
}
public String toString()
{
return String.format("(%s, %s, %s, %s, %s, %s)", t1, t2, t3, t4, t5, t6);
}
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof Tuple6<?,?,?,?,?,?>))
return false;
Tuple6<T1,T2,T3,T4,T5,T6> rhs = (Tuple6<T1,T2,T3,T4,T5,T6>) other;
if (!(this.t1==null ? rhs.t1==null : this.t1.equals(rhs.t1)))
return false;
if (!(this.t2==null ? rhs.t2==null : this.t2.equals(rhs.t2)))
return false;
if (!(this.t3==null ? rhs.t3==null : this.t3.equals(rhs.t3)))
return false;
if (!(this.t4==null ? rhs.t4==null : this.t4.equals(rhs.t4)))
return false;
if (!(this.t5==null ? rhs.t5==null : this.t5.equals(rhs.t5)))
return false;
if (!(this.t6==null ? rhs.t6==null : this.t6.equals(rhs.t6)))
return false;
return true;
}
public int getHashCode() {
int hash = 1;
hash *= 31 + (t1 == null ? 0 : t1.hashCode());
hash *= 31 + (t2 == null ? 0 : t2.hashCode());
hash *= 31 + (t3 == null ? 0 : t3.hashCode());
hash *= 31 + (t4 == null ? 0 : t4.hashCode());
hash *= 31 + (t5 == null ? 0 : t5.hashCode());
hash *= 31 + (t6 == null ? 0 : t6.hashCode());
return hash;
}
}