Add equals(), hashCode() & toString() methods

pull/10/head
Hammy 4 years ago
parent ff0f82a8d4
commit 2b25cc8f6d

@ -3,6 +3,8 @@ package me.goudham;
import me.goudham.domain.series.Series;
import me.goudham.domain.waifu.Waifu;
import java.util.Objects;
/**
* This is returned to the User when called by methods in {@link MyWaifuClient}.
* E.g {@link MyWaifuClient#getWaifu(Integer)}
@ -38,4 +40,26 @@ public class Response<T> {
public String getBody() {
return body;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Response<?> response = (Response<?>) o;
return Objects.equals(model, response.model) && Objects.equals(statusCode, response.statusCode) && Objects.equals(body, response.body);
}
@Override
public int hashCode() {
return Objects.hash(model, statusCode, body);
}
@Override
public String toString() {
return "Response{" +
"model=" + model +
", statusCode=" + statusCode +
", body='" + body + '\'' +
'}';
}
}

@ -1,6 +1,7 @@
package me.goudham;
import java.net.http.HttpRequest;
import java.util.Objects;
/**
* Represents a Result from a {@link HttpRequest} with the resulting
@ -22,4 +23,25 @@ class Result {
String getBody() {
return body;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Result result = (Result) o;
return Objects.equals(statusCode, result.statusCode) && Objects.equals(body, result.body);
}
@Override
public int hashCode() {
return Objects.hash(statusCode, body);
}
@Override
public String toString() {
return "Result{" +
"statusCode=" + statusCode +
", body='" + body + '\'' +
'}';
}
}

Loading…
Cancel
Save