Merge "Define equals and hashCode for InputDeviceIdentifier." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c81b726ed1
@@ -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>() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user