KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > Tuple4


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

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