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

Add toString, hashcode and equals to OfflineRegionError. #14499

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.offline;

import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.StringDef;

import java.lang.annotation.Retention;
Expand All @@ -25,31 +26,67 @@ public class OfflineRegionError {
public static final String REASON_CONNECTION = "REASON_CONNECTION";
public static final String REASON_OTHER = "REASON_OTHER";

@NonNull
@ErrorReason
private final String reason;

/**
* /* An error message from the request handler, e.g. a server message or a system message
* /* informing the user about the reason for the failure.
*/
@NonNull
private final String message;

// Constructors
@Keep
private OfflineRegionError(String reason, String message) {
private OfflineRegionError(@NonNull String reason, @NonNull String message) {
// For JNI use only
this.reason = reason;
this.message = message;
}

// Getters

@NonNull
@ErrorReason
public String getReason() {
return reason;
}

@NonNull
public String getMessage() {
return message;
}
}

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

OfflineRegionError that = (OfflineRegionError) o;

if (!reason.equals(that.reason)) {
return false;
}
return message.equals(that.message);
}

@Override
public int hashCode() {
int result = reason.hashCode();
result = 31 * result + message.hashCode();
return result;
}

@Override
public String toString() {
return "OfflineRegionError{"
+ "reason='" + reason + '\''
+ ", message='" + message + '\''
+ '}';
}
}