View Javadoc
1   package com.github.davidmoten.rx.jdbc.tuple;
2   
3   /**
4    * An explicitly typed tuple.
5    * 
6    * @param <T1>
7    * @param <T2>
8    * @param <T3>
9    * @param <T4>
10   */
11  public class Tuple4<T1, T2, T3, T4> {
12  
13      private final T1 value1;
14      private final T2 value2;
15      private final T3 value3;
16      private final T4 value4;
17  
18      /**
19       * Constructor.
20       * 
21       * @param value1
22       * @param value2
23       * @param value3
24       * @param value4
25       */
26      public Tuple4(T1 value1, T2 value2, T3 value3, T4 value4) {
27          this.value1 = value1;
28          this.value2 = value2;
29          this.value3 = value3;
30          this.value4 = value4;
31      }
32  
33      public T1 value1() {
34          return value1;
35      }
36  
37      public T2 value2() {
38          return value2;
39      }
40  
41      public T3 value3() {
42          return value3;
43      }
44  
45      public T4 value4() {
46          return value4;
47      }
48  
49      @Override
50      public int hashCode() {
51          final int prime = 31;
52          int result = 1;
53          result = prime * result + ((value1 == null) ? 0 : value1.hashCode());
54          result = prime * result + ((value2 == null) ? 0 : value2.hashCode());
55          result = prime * result + ((value3 == null) ? 0 : value3.hashCode());
56          result = prime * result + ((value4 == null) ? 0 : value4.hashCode());
57          return result;
58      }
59  
60      @Override
61      public boolean equals(Object obj) {
62          if (this == obj)
63              return true;
64          if (obj == null)
65              return false;
66          if (getClass() != obj.getClass())
67              return false;
68          Tuple4<?, ?, ?, ?> other = (Tuple4<?, ?, ?, ?>) obj;
69          if (value1 == null) {
70              if (other.value1 != null)
71                  return false;
72          } else if (!value1.equals(other.value1))
73              return false;
74          if (value2 == null) {
75              if (other.value2 != null)
76                  return false;
77          } else if (!value2.equals(other.value2))
78              return false;
79          if (value3 == null) {
80              if (other.value3 != null)
81                  return false;
82          } else if (!value3.equals(other.value3))
83              return false;
84          if (value4 == null) {
85              if (other.value4 != null)
86                  return false;
87          } else if (!value4.equals(other.value4))
88              return false;
89          return true;
90      }
91  
92      @Override
93      public String toString() {
94          return "Tuple4 [value1=" + value1 + ", value2=" + value2 + ", value3=" + value3
95                  + ", value4=" + value4 + "]";
96      }
97  
98  }