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