Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add hashcode(), equals() and toString() methods to Events class.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin committed Apr 10, 2019
1 parent a8239aa commit 61de9ad
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,91 @@ boolean isWifi() {
return wifi;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

MapClickEvent that = (MapClickEvent) o;

if (Double.compare(that.latitude, latitude) != 0) {
return false;
}
if (Double.compare(that.longitude, longitude) != 0) {
return false;
}
if (Double.compare(that.zoom, zoom) != 0) {
return false;
}
if (batteryLevel != that.batteryLevel) {
return false;
}
if (pluggedIn != that.pluggedIn) {
return false;
}
if (wifi != that.wifi) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (gesture != null ? !gesture.equals(that.gesture) : that.gesture != null) {
return false;
}
if (cellularNetworkType != null ? !cellularNetworkType.equals(that.cellularNetworkType) :
that.cellularNetworkType != null) {
return false;
}
if (carrier != null ? !carrier.equals(that.carrier) : that.carrier != null) {
return false;
}
return orientation != null ? orientation.equals(that.orientation) : that.orientation == null;
}

@Override
public int hashCode() {
int result;
long temp;
result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (gesture != null ? gesture.hashCode() : 0);
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
temp = Double.doubleToLongBits(latitude);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(longitude);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(zoom);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + batteryLevel;
result = 31 * result + (pluggedIn ? 1 : 0);
result = 31 * result + (wifi ? 1 : 0);
return result;
}

@Override
public String toString() {
return "MapClickEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", gesture='" + gesture + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
+ ", carrier='" + carrier + '\''
+ ", orientation='" + orientation + '\''
+ ", latitude=" + latitude
+ ", longitude=" + longitude
+ ", zoom=" + zoom
+ ", batteryLevel=" + batteryLevel
+ ", pluggedIn=" + pluggedIn
+ ", wifi=" + wifi
+ '}';
}

@Override
public int describeContents() {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,86 @@ boolean isWifi() {
return wifi;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

MapDragendEvent that = (MapDragendEvent) o;

if (batteryLevel != that.batteryLevel) {
return false;
}
if (Double.compare(that.lat, lat) != 0) {
return false;
}
if (Double.compare(that.lng, lng) != 0) {
return false;
}
if (Double.compare(that.zoom, zoom) != 0) {
return false;
}
if (pluggedIn != that.pluggedIn) {
return false;
}
if (wifi != that.wifi) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (orientation != null ? !orientation.equals(that.orientation) : that.orientation != null) {
return false;
}
if (carrier != null ? !carrier.equals(that.carrier) : that.carrier != null) {
return false;
}
return cellularNetworkType != null ? cellularNetworkType.equals(that.cellularNetworkType) :
that.cellularNetworkType == null;
}

@Override
public int hashCode() {
int result;
long temp;
result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
result = 31 * result + batteryLevel;
temp = Double.doubleToLongBits(lat);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(lng);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(zoom);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (pluggedIn ? 1 : 0);
result = 31 * result + (wifi ? 1 : 0);
return result;
}

@Override
public String toString() {
return "MapDragendEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", orientation='" + orientation + '\''
+ ", carrier='" + carrier + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
+ ", batteryLevel=" + batteryLevel
+ ", lat=" + lat
+ ", lng=" + lng
+ ", zoom=" + zoom
+ ", pluggedIn=" + pluggedIn
+ ", wifi=" + wifi
+ '}';
}

@Override
public int describeContents() {
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.mapbox.mapboxsdk.module.telemetry;

import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;

import com.mapbox.android.telemetry.TelemetryUtils;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.offline.OfflineRegion;

class MapEventFactory {

Expand All @@ -13,7 +16,10 @@ static MapLoadEvent buildMapLoadEvent(@NonNull PhoneState phoneState) {

static OfflineDownloadStartEvent buildOfflineDownloadStartEvent(PhoneState phoneState,
String shapeForOfflineRegion,
Double minZoom, Double maxZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double minZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double maxZoom,
String styleURL) {

OfflineDownloadStartEvent offlineEvent =
Expand All @@ -24,11 +30,14 @@ static OfflineDownloadStartEvent buildOfflineDownloadStartEvent(PhoneState phone

static OfflineDownloadEndEvent buildOfflineDownloadCompleteEvent(PhoneState phoneState,
String shapeForOfflineRegion,
Double minZoom, Double maxZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double minZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double maxZoom,
String styleURL,
Long sizeOfResourcesCompleted,
Long numberOfTilesCompleted,
String state) {
@OfflineRegion.DownloadState int state) {

OfflineDownloadEndEvent offlineEvent =
new OfflineDownloadEndEvent(phoneState, shapeForOfflineRegion, minZoom, maxZoom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,95 @@ boolean isWifi() {
return wifi;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

MapLoadEvent that = (MapLoadEvent) o;

if (Float.compare(that.resolution, resolution) != 0) {
return false;
}
if (Float.compare(that.accessibilityFontScale, accessibilityFontScale) != 0) {
return false;
}
if (batteryLevel != that.batteryLevel) {
return false;
}
if (pluggedIn != that.pluggedIn) {
return false;
}
if (wifi != that.wifi) {
return false;
}
if (!operatingSystem.equals(that.operatingSystem)) {
return false;
}
if (model != null ? !model.equals(that.model) : that.model != null) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (userId != null ? !userId.equals(that.userId) : that.userId != null) {
return false;
}
if (carrier != null ? !carrier.equals(that.carrier) : that.carrier != null) {
return false;
}
if (cellularNetworkType != null ? !cellularNetworkType.equals(that.cellularNetworkType) :
that.cellularNetworkType != null) {
return false;
}
return orientation != null ? orientation.equals(that.orientation) : that.orientation == null;
}

@Override
public int hashCode() {
int result = event.hashCode();
result = 31 * result + operatingSystem.hashCode();
result = 31 * result + sdkIdentifier.hashCode();
result = 31 * result + sdkVersion.hashCode();
result = 31 * result + (model != null ? model.hashCode() : 0);
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
result = 31 * result + (resolution != +0.0f ? Float.floatToIntBits(resolution) : 0);
result = 31 * result + (accessibilityFontScale != +0.0f ? Float.floatToIntBits(accessibilityFontScale) : 0);
result = 31 * result + batteryLevel;
result = 31 * result + (pluggedIn ? 1 : 0);
result = 31 * result + (wifi ? 1 : 0);
return result;
}

@Override
public String toString() {
return "MapLoadEvent{"
+ "event='" + event + '\''
+ ", operatingSystem='" + operatingSystem + '\''
+ ", sdkIdentifier='" + sdkIdentifier + '\''
+ ", sdkVersion='" + sdkVersion + '\''
+ ", model='" + model + '\''
+ ", created='" + created + '\''
+ ", userId='" + userId + '\''
+ ", carrier='" + carrier + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
+ ", orientation='" + orientation + '\''
+ ", resolution=" + resolution
+ ", accessibilityFontScale=" + accessibilityFontScale
+ ", batteryLevel=" + batteryLevel
+ ", pluggedIn=" + pluggedIn
+ ", wifi=" + wifi
+ '}';
}

@Override
public int describeContents() {
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.mapbox.mapboxsdk.module.telemetry;

import android.support.annotation.FloatRange;

import com.mapbox.mapboxsdk.constants.MapboxConstants;

public class MapState {
private double latitude;
private double longitude;
private double zoom;
private String gesture;

MapState(double latitude, double longitude, double zoom) {
MapState(double latitude, double longitude, @FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) double zoom) {
this.latitude = latitude;
this.longitude = longitude;
this.zoom = zoom;
Expand Down
Loading

0 comments on commit 61de9ad

Please sign in to comment.