aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/model/CellTower.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/model/CellTower.java')
-rw-r--r--src/main/java/org/traccar/model/CellTower.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/model/CellTower.java b/src/main/java/org/traccar/model/CellTower.java
index 254487471..355594c64 100644
--- a/src/main/java/org/traccar/model/CellTower.java
+++ b/src/main/java/org/traccar/model/CellTower.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,11 @@
package org.traccar.model;
import com.fasterxml.jackson.annotation.JsonInclude;
-import org.traccar.Context;
+import org.traccar.config.Config;
import org.traccar.config.Keys;
+import java.util.Objects;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CellTower {
@@ -37,14 +39,12 @@ public class CellTower {
return cellTower;
}
- public static CellTower fromLacCid(int lac, long cid) {
- return from(
- Context.getConfig().getInteger(Keys.GEOLOCATION_MCC),
- Context.getConfig().getInteger(Keys.GEOLOCATION_MCC), lac, cid);
+ public static CellTower fromLacCid(Config config, int lac, long cid) {
+ return from(config.getInteger(Keys.GEOLOCATION_MCC), config.getInteger(Keys.GEOLOCATION_MNC), lac, cid);
}
- public static CellTower fromCidLac(long cid, int lac) {
- return fromLacCid(lac, cid);
+ public static CellTower fromCidLac(Config config, long cid, int lac) {
+ return fromLacCid(config, lac, cid);
}
private String radioType;
@@ -113,4 +113,26 @@ public class CellTower {
mobileNetworkCode = Integer.parseInt(operatorString.substring(3));
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ CellTower cellTower = (CellTower) o;
+ return Objects.equals(radioType, cellTower.radioType)
+ && Objects.equals(cellId, cellTower.cellId)
+ && Objects.equals(locationAreaCode, cellTower.locationAreaCode)
+ && Objects.equals(mobileCountryCode, cellTower.mobileCountryCode)
+ && Objects.equals(mobileNetworkCode, cellTower.mobileNetworkCode)
+ && Objects.equals(signalStrength, cellTower.signalStrength);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(radioType, cellId, locationAreaCode, mobileCountryCode, mobileNetworkCode, signalStrength);
+ }
+
}