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