View Javadoc
1   package org.davidmoten.rx.jdbc.tuple;
2   
3   /**
4    * An explicitly typed tuple.
5    * 
6    * @param <T1>
7    *            type of first element
8    * @param <T2>
9    *            type of second element
10   * @param <T3>
11   *            type of third element
12   * @param <T4>
13   *            type of fourth element
14   * @param <T5>
15   *            type of fifth element
16   * @param <T6>
17   *            type of sixth element
18   */
19  public class Tuple6<T1, T2, T3, T4, T5, T6> {
20  
21      private final T1 value1;
22      private final T2 value2;
23      private final T3 value3;
24      private final T4 value4;
25      private final T5 value5;
26      private final T6 value6;
27  
28      /**
29       * Constructor.
30       * 
31       * @param value1
32       *            first element
33       * @param value2
34       *            second element
35       * @param value3
36       *            third element
37       * @param value4
38       *            fourth element
39       * @param value5
40       *            fifth element
41       * @param value6
42       *            sixth element
43       */
44      public Tuple6(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
45          this.value1 = value1;
46          this.value2 = value2;
47          this.value3 = value3;
48          this.value4 = value4;
49          this.value5 = value5;
50          this.value6 = value6;
51      }
52  
53      public static <T1, T2, T3, T4, T5, T6> Tuple6<T1, T2, T3, T4, T5, T6> create(T1 value1,
54              T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
55          return new Tuple6<T1, T2, T3, T4, T5, T6>(value1, value2, value3, value4, value5, value6);
56      }
57  
58      public T1 value1() {
59          return value1;
60      }
61  
62      public T2 value2() {
63          return value2;
64      }
65  
66      public T3 value3() {
67          return value3;
68      }
69  
70      public T4 value4() {
71          return value4;
72      }
73  
74      public T5 value5() {
75          return value5;
76      }
77  
78      public T6 value6() {
79          return value6;
80      }
81  
82      public T1 _1() {
83          return value1;
84      }
85  
86      public T2 _2() {
87          return value2;
88      }
89  
90      public T3 _3() {
91          return value3;
92      }
93  
94      public T4 _4() {
95          return value4;
96      }
97  
98      public T5 _5() {
99          return value5;
100     }
101 
102     public T6 _6() {
103         return value6;
104     }
105 
106     @Override
107     public int hashCode() {
108         final int prime = 31;
109         int result = 1;
110         result = prime * result + ((value1 == null) ? 0 : value1.hashCode());
111         result = prime * result + ((value2 == null) ? 0 : value2.hashCode());
112         result = prime * result + ((value3 == null) ? 0 : value3.hashCode());
113         result = prime * result + ((value4 == null) ? 0 : value4.hashCode());
114         result = prime * result + ((value5 == null) ? 0 : value5.hashCode());
115         result = prime * result + ((value6 == null) ? 0 : value6.hashCode());
116         return result;
117     }
118 
119     @Override
120     public boolean equals(Object obj) {
121         if (this == obj)
122             return true;
123         if (obj == null)
124             return false;
125         if (getClass() != obj.getClass())
126             return false;
127         Tuple6<?, ?, ?, ?, ?, ?> other = (Tuple6<?, ?, ?, ?, ?, ?>) obj;
128         if (value1 == null) {
129             if (other.value1 != null)
130                 return false;
131         } else if (!value1.equals(other.value1))
132             return false;
133         if (value2 == null) {
134             if (other.value2 != null)
135                 return false;
136         } else if (!value2.equals(other.value2))
137             return false;
138         if (value3 == null) {
139             if (other.value3 != null)
140                 return false;
141         } else if (!value3.equals(other.value3))
142             return false;
143         if (value4 == null) {
144             if (other.value4 != null)
145                 return false;
146         } else if (!value4.equals(other.value4))
147             return false;
148         if (value5 == null) {
149             if (other.value5 != null)
150                 return false;
151         } else if (!value5.equals(other.value5))
152             return false;
153         if (value6 == null) {
154             if (other.value6 != null)
155                 return false;
156         } else if (!value6.equals(other.value6))
157             return false;
158         return true;
159     }
160 
161     @Override
162     public String toString() {
163         return "Tuple6 [value1=" + value1 + ", value2=" + value2 + ", value3=" + value3
164                 + ", value4=" + value4 + ", value5=" + value5 + ", value6=" + value6 + "]";
165     }
166 }