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
50 return type;
51 }
52
67 return values;
68 }
69
83 public long getTime() {
84 return time;
85 }
86
87 @Override
88 public boolean equals(Object obj) {
89 if (!(obj instanceof SensorMeasurement)) {
90 return false;
91 }
93 return this.type == other.type &&
94 this.values.equals(other.values) &&
95 this.time == other.time;
96 }
97
98 @Override
99 public int hashCode() {
100 // Pick an arbitrary non-zero starting value
101 int hashCode = 17;
102 hashCode = hashCode * 31 + type.hashCode();
103 hashCode = hashCode * 31 + values.hashCode();
104 hashCode = hashCode * 31 + ((int) (time ^ (time >>> 32)));
105 return hashCode;
106 }
107
108 @Override
109 public String toString() {
110 return "SensorMeasurement{" +
111 "type=" + type +
112 "," + "values=" + values +
113 "," + "time=" + time +
114 "}";
115 }
116
117
118 @Override
119 public int compareTo(SensorMeasurement other) {
120 int tempResult;
121 tempResult = this.type.compareTo(other.type);if (tempResult != 0) {
122 return tempResult;
123 }
124 tempResult = this.values.compareTo(other.values);
125 if (tempResult != 0) {
126 return tempResult;
127 }
128 if (this.time < other.time) {
129 tempResult = -1;
130 } else if (this.time > other.time) {
131 tempResult = 1;
132 } else {
133 tempResult = 0;
134 }
135 if (tempResult != 0) {
136 return tempResult;
137 }
138 return 0;
139 }
140}