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

Commit 69343de8 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Add ImeSubtypeListItem equals and hashCode

This changes the equals method of the ImeSubtypeListItem to take into
account all the fields, and also adds the hashCode implementation for
the class.

Flag: EXEMPT cleanup
Bug: 347693610
Test: atest InputMethodSubtypeSwitchingControllerTest
Change-Id: I78ee0bb2eee56dd98095e60c87472ab57d10d3de
parent 7eaf0f8b
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -196,15 +196,28 @@ final class InputMethodSubtypeSwitchingController {
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) {
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            }
            if (o instanceof ImeSubtypeListItem that) {
                return Objects.equals(mImi, that.mImi) && mSubtypeIndex == that.mSubtypeIndex;
            }
            if (!(obj instanceof ImeSubtypeListItem that)) {
                return false;
            }
            return TextUtils.equals(mImeName, that.mImeName)
                    && TextUtils.equals(mSubtypeName, that.mSubtypeName)
                    && TextUtils.equals(mLayoutName, that.mLayoutName)
                    && mImi.equals(that.mImi)
                    && mSubtypeIndex == that.mSubtypeIndex
                    && mShowInImeSwitcherMenu == that.mShowInImeSwitcherMenu
                    && mIsAuxiliary == that.mIsAuxiliary
                    && mSuitableForHardware == that.mSuitableForHardware;
        }

        @Override
        public int hashCode() {
            return Objects.hash(mImeName, mSubtypeName, mLayoutName, mImi, mSubtypeIndex,
                    mShowInImeSwitcherMenu, mIsAuxiliary, mSuitableForHardware);
        }

        /**
         * Compares two character sequences lexicographically. For historical reasons, an empty