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

This commit is contained in:
Keisuke Kuroyanagi
2016-04-19 04:11:15 +00:00
committed by Android (Google) Code Review

View File

@@ -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>() {