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

Commit c81b726e authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Define equals and hashCode for InputDeviceIdentifier." into nyc-dev

parents 1ed0c12a 07ff292d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package android.hardware.input;

import java.util.Objects;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Wrapper for passing identifying information for input devices.
@@ -65,6 +68,21 @@ public final class InputDeviceIdentifier implements Parcelable {
        return mProductId;
    }

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

        final InputDeviceIdentifier that = (InputDeviceIdentifier) o;
        return ((mVendorId == that.mVendorId) && (mProductId == that.mProductId)
                && TextUtils.equals(mDescriptor, that.mDescriptor));
    }

    @Override
    public int hashCode() {
        return Objects.hash(mDescriptor, mVendorId, mProductId);
    }

    public static final Parcelable.Creator<InputDeviceIdentifier> CREATOR =
            new Parcelable.Creator<InputDeviceIdentifier>() {