Loading...
Searching...
No Matches
SignalMeasurement.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
15public final class SignalMeasurement implements Comparable<SignalMeasurement> {
16
17
18 /*package*/ final SignalType type;
19
20 /*package*/ final String id;
21
22 /*package*/ final float rssi;
23
24 /*package*/ final float distance;
25
26 /*package*/ final long time;
27
32 SignalType type,
33 String id,
34 float rssi,
35 float distance,
36 long time) {
37 this.type = type;
38 this.id = id;
39 this.rssi = rssi;
40 this.distance = distance;
41 this.time = time;
42 }
43
58 return type;
59 }
60
74 public String getId() {
75 return id;
76 }
77
91 public float getRssi() {
92 return rssi;
93 }
94
108 public float getDistance() {
109 return distance;
110 }
111
125 public long getTime() {
126 return time;
127 }
128
129 @Override
130 public boolean equals(Object obj) {
131 if (!(obj instanceof SignalMeasurement)) {
132 return false;
133 }
135 return this.type == other.type &&
136 this.id.equals(other.id) &&
137 this.rssi == other.rssi &&
138 this.distance == other.distance &&
139 this.time == other.time;
140 }
141
142 @Override
143 public int hashCode() {
144 // Pick an arbitrary non-zero starting value
145 int hashCode = 17;
146 hashCode = hashCode * 31 + type.hashCode();
147 hashCode = hashCode * 31 + id.hashCode();
148 hashCode = hashCode * 31 + Float.floatToIntBits(rssi);
149 hashCode = hashCode * 31 + Float.floatToIntBits(distance);
150 hashCode = hashCode * 31 + ((int) (time ^ (time >>> 32)));
151 return hashCode;
152 }
153
154 @Override
155 public String toString() {
156 return "SignalMeasurement{" +
157 "type=" + type +
158 "," + "id=" + id +
159 "," + "rssi=" + rssi +
160 "," + "distance=" + distance +
161 "," + "time=" + time +
162 "}";
163 }
164
165
166 @Override
167 public int compareTo(SignalMeasurement other) {
168 int tempResult;
169 tempResult = this.type.compareTo(other.type);if (tempResult != 0) {
170 return tempResult;
171 }
172 tempResult = this.id.compareTo(other.id);
173 if (tempResult != 0) {
174 return tempResult;
175 }
176 if (this.rssi < other.rssi) {
177 tempResult = -1;
178 } else if (this.rssi > other.rssi) {
179 tempResult = 1;
180 } else {
181 tempResult = 0;
182 }
183 if (tempResult != 0) {
184 return tempResult;
185 }
186 if (this.distance < other.distance) {
187 tempResult = -1;
188 } else if (this.distance > other.distance) {
189 tempResult = 1;
190 } else {
191 tempResult = 0;
192 }
193 if (tempResult != 0) {
194 return tempResult;
195 }
196 if (this.time < other.time) {
197 tempResult = -1;
198 } else if (this.time > other.time) {
199 tempResult = 1;
200 } else {
201 tempResult = 0;
202 }
203 if (tempResult != 0) {
204 return tempResult;
205 }
206 return 0;
207 }
208}