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
57 return type;
58 }
59
72 public String getId() {
73 return id;
74 }
75
88 public float getRssi() {
89 return rssi;
90 }
91
104 public float getDistance() {
105 return distance;
106 }
107
120 public long getTime() {
121 return time;
122 }
123
124 @Override
125 public boolean equals(Object obj) {
126 if (!(obj instanceof SignalMeasurement)) {
127 return false;
128 }
130 return this.type == other.type &&
131 this.id.equals(other.id) &&
132 this.rssi == other.rssi &&
133 this.distance == other.distance &&
134 this.time == other.time;
135 }
136
137 @Override
138 public int hashCode() {
139 // Pick an arbitrary non-zero starting value
140 int hashCode = 17;
141 hashCode = hashCode * 31 + type.hashCode();
142 hashCode = hashCode * 31 + id.hashCode();
143 hashCode = hashCode * 31 + Float.floatToIntBits(rssi);
144 hashCode = hashCode * 31 + Float.floatToIntBits(distance);
145 hashCode = hashCode * 31 + ((int) (time ^ (time >>> 32)));
146 return hashCode;
147 }
148
149 @Override
150 public String toString() {
151 return "SignalMeasurement{" +
152 "type=" + type +
153 "," + "id=" + id +
154 "," + "rssi=" + rssi +
155 "," + "distance=" + distance +
156 "," + "time=" + time +
157 "}";
158 }
159
160
161 @Override
162 public int compareTo(SignalMeasurement other) {
163 int tempResult;
164 tempResult = this.type.compareTo(other.type);if (tempResult != 0) {
165 return tempResult;
166 }
167 tempResult = this.id.compareTo(other.id);
168 if (tempResult != 0) {
169 return tempResult;
170 }
171 if (this.rssi < other.rssi) {
172 tempResult = -1;
173 } else if (this.rssi > other.rssi) {
174 tempResult = 1;
175 } else {
176 tempResult = 0;
177 }
178 if (tempResult != 0) {
179 return tempResult;
180 }
181 if (this.distance < other.distance) {
182 tempResult = -1;
183 } else if (this.distance > other.distance) {
184 tempResult = 1;
185 } else {
186 tempResult = 0;
187 }
188 if (tempResult != 0) {
189 return tempResult;
190 }
191 if (this.time < other.time) {
192 tempResult = -1;
193 } else if (this.time > other.time) {
194 tempResult = 1;
195 } else {
196 tempResult = 0;
197 }
198 if (tempResult != 0) {
199 return tempResult;
200 }
201 return 0;
202 }
203}