Skip to content

Commit ff0e170

Browse files
SUPERCILEXsamtstern
authored andcommitted
POJOize IdpResponse (#1177)
1 parent 43b391c commit ff0e170

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

auth/src/main/java/com/firebase/ui/auth/IdpResponse.java

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@
3232
* A container that encapsulates the result of authenticating with an Identity Provider.
3333
*/
3434
public class IdpResponse implements Parcelable {
35+
public static final Creator<IdpResponse> CREATOR = new Creator<IdpResponse>() {
36+
@Override
37+
public IdpResponse createFromParcel(Parcel in) {
38+
return new IdpResponse(
39+
in.<User>readParcelable(User.class.getClassLoader()),
40+
in.readString(),
41+
in.readString(),
42+
(FirebaseUiException) in.readSerializable()
43+
);
44+
}
45+
46+
@Override
47+
public IdpResponse[] newArray(int size) {
48+
return new IdpResponse[size];
49+
}
50+
};
51+
3552
private final User mUser;
3653

3754
private final String mToken;
@@ -181,22 +198,37 @@ public void writeToParcel(Parcel dest, int flags) {
181198
dest.writeSerializable(mException);
182199
}
183200

184-
public static final Creator<IdpResponse> CREATOR = new Creator<IdpResponse>() {
185-
@Override
186-
public IdpResponse createFromParcel(Parcel in) {
187-
return new IdpResponse(
188-
in.<User>readParcelable(User.class.getClassLoader()),
189-
in.readString(),
190-
in.readString(),
191-
(FirebaseUiException) in.readSerializable()
192-
);
193-
}
201+
@Override
202+
public boolean equals(Object o) {
203+
if (this == o) return true;
204+
if (o == null || getClass() != o.getClass()) return false;
194205

195-
@Override
196-
public IdpResponse[] newArray(int size) {
197-
return new IdpResponse[size];
198-
}
199-
};
206+
IdpResponse response = (IdpResponse) o;
207+
208+
return (mUser == null ? response.mUser == null : mUser.equals(response.mUser))
209+
&& (mToken == null ? response.mToken == null : mToken.equals(response.mToken))
210+
&& (mSecret == null ? response.mSecret == null : mSecret.equals(response.mSecret))
211+
&& (mException == null ? response.mException == null : mException.equals(response.mException));
212+
}
213+
214+
@Override
215+
public int hashCode() {
216+
int result = mUser == null ? 0 : mUser.hashCode();
217+
result = 31 * result + (mToken == null ? 0 : mToken.hashCode());
218+
result = 31 * result + (mSecret == null ? 0 : mSecret.hashCode());
219+
result = 31 * result + (mException == null ? 0 : mException.hashCode());
220+
return result;
221+
}
222+
223+
@Override
224+
public String toString() {
225+
return "IdpResponse{" +
226+
"mUser=" + mUser +
227+
", mToken='" + mToken + '\'' +
228+
", mSecret='" + mSecret + '\'' +
229+
", mException=" + mException +
230+
'}';
231+
}
200232

201233
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
202234
public static class Builder {

0 commit comments

Comments
 (0)