1 package org.opentrafficsim.base;
2
3 import java.io.Serializable;
4
5 import org.djunits.value.vdouble.scalar.Time;
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class TimeStampedObject<C> implements Serializable
20 {
21
22 private static final long serialVersionUID = 20160129L;
23
24
25 private final C object;
26
27
28 private final Time timestamp;
29
30
31
32
33
34
35 public TimeStampedObject(final C object, final Time timestamp)
36 {
37 this.object = object;
38 this.timestamp = timestamp;
39 }
40
41
42
43
44
45 public final C getObject()
46 {
47 return this.object;
48 }
49
50
51
52
53
54 public final Time getTimestamp()
55 {
56 return this.timestamp;
57 }
58
59
60 @Override
61 public final String toString()
62 {
63 return "TimeStampedObject [object=" + this.object + ", timestamp=" + this.timestamp + "]";
64 }
65
66 @Override
67 public int hashCode()
68 {
69 final int prime = 31;
70 int result = 1;
71 result = prime * result + ((object == null) ? 0 : object.hashCode());
72 result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
73 return result;
74 }
75
76 @Override
77 public boolean equals(Object obj)
78 {
79 if (this == obj)
80 return true;
81 if (obj == null)
82 return false;
83 if (getClass() != obj.getClass())
84 return false;
85 TimeStampedObjectrg/opentrafficsim/base/TimeStampedObject.html#TimeStampedObject">TimeStampedObject other = (TimeStampedObject) obj;
86 if (object == null)
87 {
88 if (other.object != null)
89 return false;
90 }
91 else if (!object.equals(other.object))
92 return false;
93 if (timestamp == null)
94 {
95 if (other.timestamp != null)
96 return false;
97 }
98 else if (!timestamp.equals(other.timestamp))
99 return false;
100 return true;
101 }
102
103 }