Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92adc794 authored by Omer Ozer's avatar Omer Ozer Committed by Automerger Merge Worker
Browse files

Merge "Add hash and equals to CredentialDesc" into udc-dev am: 73d2da21 am: f7b3aa97

parents e6e9873b f7b3aa97
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public final class CredentialDescription implements Parcelable {
    private final String mType;

    /**
     * The flattened JSON string that will be matched with requests.
     * Flattened semicolon separated keys of JSON values to match with requests.
     */
    @NonNull
    private final String mFlattenedRequestString;
@@ -57,7 +57,8 @@ public final class CredentialDescription implements Parcelable {
     * Constructs a {@link CredentialDescription}.
     *
     * @param type the type of the credential returned.
     * @param flattenedRequestString flattened JSON string that will be matched with requests.
     * @param flattenedRequestString flattened semicolon separated keys of JSON values
     *                              to match with requests.
     * @param credentialEntries a list of {@link CredentialEntry}s that are to be shown on the
     *                          account selector if a credential matches with this description.
     *                          Each entry contains information to be displayed within an
@@ -151,4 +152,29 @@ public final class CredentialDescription implements Parcelable {
    public List<CredentialEntry> getCredentialEntries() {
        return mCredentialEntries;
    }

    /**
     * {@link CredentialDescription#mType} and
     * {@link CredentialDescription#mFlattenedRequestString} are enough for hashing. Constructor
     * enforces {@link CredentialEntry} to have the same type and
     * {@link android.app.slice.Slice} contained by the entry can not be hashed.
     */
    @Override
    public int hashCode() {
        return Objects.hash(mType, mFlattenedRequestString);
    }

    /**
     * {@link CredentialDescription#mType} and
     * {@link CredentialDescription#mFlattenedRequestString} are enough for equality check.
     */
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof CredentialDescription)) {
            return false;
        }
        CredentialDescription other = (CredentialDescription) obj;
        return mType.equals(other.mType)
                && mFlattenedRequestString.equals(other.mFlattenedRequestString);
    }
}