1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package com.ebay.carad.os.vitalsigns;
22
23 import org.apache.commons.lang.builder.EqualsBuilder;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.apache.commons.lang.builder.ToStringBuilder;
26
27 /***
28 * <p>A point of data logged at a given time, which represents the meat of most standard
29 * "data in timeline" type reports.</p>
30 *
31 * <p>Sorts itself in order of logtime ascending.</p>
32 *
33 * @author Jeremy Thomerson
34 * @version $Id$
35 */
36 public class DataPoint implements Comparable {
37
38
39
40 private long mLogTime;
41 private float mData;
42
43 public DataPoint() {
44 super();
45 }
46
47 public DataPoint(long logTime, float data) {
48 this();
49 setLogTime(logTime);
50 setData(data);
51 }
52
53 public float getData() {
54 return mData;
55 }
56
57 public void setData(float data) {
58 mData = data;
59 }
60
61 public long getLogTime() {
62 return mLogTime;
63 }
64
65 public void setLogTime(long logTime) {
66 mLogTime = logTime;
67 }
68
69 /***
70 * Sorts itself in order of logtime ascending.
71 * @param other the other Object to compare self to.
72 * @return see interface
73 */
74 public int compareTo(Object other) {
75 return (int) (mLogTime - ((DataPoint) other).mLogTime);
76 }
77
78 public String toString() {
79 return new ToStringBuilder(this)
80 .append("mLogTime", mLogTime)
81 .append("mData", mData)
82 .toString();
83 }
84 public boolean equals(Object other) {
85 if (!(other instanceof DataPoint)) {
86 return false;
87 }
88 DataPoint rhs = (DataPoint) other;
89 return new EqualsBuilder()
90 .append(getData(), rhs.getData())
91 .append(getLogTime(), rhs.getLogTime())
92 .isEquals();
93 }
94 public int hashCode() {
95 return new HashCodeBuilder()
96 .append(getData())
97 .append(getLogTime())
98 .toHashCode();
99 }
100 }
101