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

Commit

Permalink
[android] - add toString, hashcode and equals to OfflineRegionError.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Apr 24, 2019
1 parent 50483ca commit 261da43
Showing 1 changed file with 39 additions and 2 deletions.
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 + '\''
+ '}';
}
}

0 comments on commit 261da43

Please sign in to comment.