File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
rxjava-core/src/main/java/rx/util Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ package rx .util ;
2
+
3
+ /**
4
+ * Composite class that takes a value and a timestamp and wraps them.
5
+ */
6
+ public final class Timestamped <T > {
7
+ private final long timestampMillis ;
8
+ private final T value ;
9
+
10
+ public Timestamped (long timestampMillis , T value ) {
11
+ this .value = value ;
12
+ this .timestampMillis = timestampMillis ;
13
+ }
14
+
15
+ public long getTimestampMillis () {
16
+ return timestampMillis ;
17
+ }
18
+
19
+ public T getValue () {
20
+ return value ;
21
+ }
22
+
23
+ @ Override
24
+ public boolean equals (Object obj ) {
25
+ if (this == obj ) {
26
+ return true ;
27
+ }
28
+ if (obj == null ) {
29
+ return false ;
30
+ }
31
+ if (!(obj instanceof Timestamped )) {
32
+ return false ;
33
+ }
34
+ Timestamped <?> other = (Timestamped <?>) obj ;
35
+ if (timestampMillis != other .timestampMillis ) {
36
+ return false ;
37
+ }
38
+ if (value == null ) {
39
+ if (other .value != null ) {
40
+ return false ;
41
+ }
42
+ } else if (!value .equals (other .value )) {
43
+ return false ;
44
+ }
45
+ return true ;
46
+ }
47
+
48
+ @ Override
49
+ public int hashCode () {
50
+ final int prime = 31 ;
51
+ int result = 1 ;
52
+ result = prime * result + (int ) (timestampMillis ^ (timestampMillis ));
53
+ result = prime * result + ((value == null ) ? 0 : value .hashCode ());
54
+ return result ;
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments