KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > Tuples


1 package jfun.parsec;
2
3 /**
4  * This class is the facade to create various tuple java beans.
5  * <p>
6  * @author Ben Yu
7  * Apr 25, 2006 9:28:23 AM
8  * @since version 1.1
9  */

10 public class Tuples {
11   /**
12    * Create a Pair object.
13    * @param a the first object.
14    * @param b the 2nd object.
15    * @return the Pair object.
16    */

17   public static <A,B> Pair<A,B> pair(A a, B b){
18     return new Pair<A,B>(a,b);
19   }
20   /**
21    * Create a 3-object tuple.
22    * @param a the 1st object.
23    * @param b the 2nd object.
24    * @param c the 3rd object.
25    * @return the tuple.
26    */

27   public static <A,B,C> Tuple3<A,B,C> tuple(A a, B b, C c){
28     return new Tuple3<A,B,C>(a,b,c);
29   }
30   /**
31    * Create a 4-object tuple.
32    * @param a the 1st object.
33    * @param b the 2nd object.
34    * @param c the 3rd object.
35    * @param d the 4th object.
36    * @return the tuple.
37    */

38   public static <A,B,C,D> Tuple4<A,B,C,D> tuple(A a, B b, C c, D d){
39     return new Tuple4<A,B,C,D>(a,b,c,d);
40   }
41   /**
42    * Create a 5-object tuple.
43    * @param a the 1st object.
44    * @param b the 2nd object.
45    * @param c the 3rd object.
46    * @param d the 4th object.
47    * @param e the 5th object.
48    * @return the tuple.
49    */

50   public static <A,B,C,D,E> Tuple5<A,B,C,D,E> tuple(A a, B b, C c, D d, E e){
51     return new Tuple5<A,B,C,D,E>(a,b,c,d,e);
52   }
53 }
54
Popular Tags