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