KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > Tuple3


1 package jfun.parsec;
2
3 import jfun.util.Misc;
4
5 /**
6  * This is a simple Java Bean for 3 objects.
7  * <p>
8  * @author Ben Yu
9  * Apr 24, 2006 1:43:12 PM
10  * @param <A>
11  * @param <B>
12  * @param <C>
13  * @since version 1.1
14  */

15 public class Tuple3<A, B, C> extends Pair<A,B> {
16   private C value3;
17   public Tuple3(){}
18   public Tuple3(A value1, B value2, C value3) {
19     super(value1, value2);
20     this.value3 = value3;
21   }
22   public C getValue3() {
23     return value3;
24   }
25   public void setValue3(C value3) {
26     this.value3 = value3;
27   }
28   public boolean equals(Tuple3 other){
29     return super.equals(other) && Misc.equals(value3, other.value3);
30   }
31   @Override JavaDoc
32   public boolean equals(Object JavaDoc obj) {
33     if(obj instanceof Tuple3){
34       return equals((Tuple3)obj);
35     }
36     else return false;
37   }
38   @Override JavaDoc
39   public int hashCode() {
40     return super.hashCode()*31+Misc.hashcode(value3);
41   }
42   @Override JavaDoc
43   public String JavaDoc toString() {
44     return "("+getValue1()+","+getValue2()+","+getValue3()+")";
45   }
46 }
47
Popular Tags