Loading...
Searching...
No Matches
SensorMeasurement.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
15public final class SensorMeasurement implements Comparable<SensorMeasurement> {
16
17
18 /*package*/ final SensorType type;
19
20 /*package*/ final Vector3d values;
21
22 /*package*/ final long time;
23
28 SensorType type,
29 Vector3d values,
30 long time) {
31 this.type = type;
32 this.values = values;
33 this.time = time;
34 }
35
49 return type;
50 }
51
65 return values;
66 }
67
80 public long getTime() {
81 return time;
82 }
83
84 @Override
85 public boolean equals(Object obj) {
86 if (!(obj instanceof SensorMeasurement)) {
87 return false;
88 }
90 return this.type == other.type &&
91 this.values.equals(other.values) &&
92 this.time == other.time;
93 }
94
95 @Override
96 public int hashCode() {
97 // Pick an arbitrary non-zero starting value
98 int hashCode = 17;
99 hashCode = hashCode * 31 + type.hashCode();
100 hashCode = hashCode * 31 + values.hashCode();
101 hashCode = hashCode * 31 + ((int) (time ^ (time >>> 32)));
102 return hashCode;
103 }
104
105 @Override
106 public String toString() {
107 return "SensorMeasurement{" +
108 "type=" + type +
109 "," + "values=" + values +
110 "," + "time=" + time +
111 "}";
112 }
113
114
115 @Override
116 public int compareTo(SensorMeasurement other) {
117 int tempResult;
118 tempResult = this.type.compareTo(other.type);if (tempResult != 0) {
119 return tempResult;
120 }
121 tempResult = this.values.compareTo(other.values);
122 if (tempResult != 0) {
123 return tempResult;
124 }
125 if (this.time < other.time) {
126 tempResult = -1;
127 } else if (this.time > other.time) {
128 tempResult = 1;
129 } else {
130 tempResult = 0;
131 }
132 if (tempResult != 0) {
133 return tempResult;
134 }
135 return 0;
136 }
137}