001    package aima.util;
002    
003    /**
004     * @author Ravi Mohan
005     * 
006     */
007    
008    public class Triplet<X, Y, Z> {
009            private final X x;
010    
011            private final Y y;
012    
013            private final Z z;
014    
015            public Triplet(X x, Y y, Z z) {
016                    this.x = x;
017                    this.y = y;
018                    this.z = z;
019            }
020    
021            public X getFirst() {
022                    return x;
023            }
024    
025            public Y getSecond() {
026                    return y;
027            }
028    
029            public Z getThird() {
030                    return z;
031            }
032    
033            @Override
034            public boolean equals(Object o) {
035                    Triplet<X, Y, Z> other = (Triplet<X, Y, Z>) o;
036                    return (x.equals(other.x)) && (y.equals(other.y))
037                                    && (z.equals(other.z));
038            }
039    
040            @Override
041            public int hashCode() {
042                    return x.hashCode() + 31 * y.hashCode() + 31 * z.hashCode();
043            }
044    
045            @Override
046            public String toString() {
047                    return "< " + x.toString() + " , " + y.toString() + " , "
048                                    + z.toString() + " >";
049            }
050    
051    }