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

Commit 705d2ea6 authored by Stephen Hines's avatar Stephen Hines
Browse files

Override equals()/hashCode() for RS BaseObj.

This will be used by slang reflection to type-check parameters to functions
that are of Allocation types (such as what happens with forEach).

BUG=4203264

Change-Id: I2ba94531bbf53becf7695b253e1faa3dff099894
parent 40f4efe7
Loading
Loading
Loading
Loading
+30 −0
Original line number Original line Diff line number Diff line
@@ -134,5 +134,35 @@ public class BaseObj {
        mName = mRS.nGetName(getID());
        mName = mRS.nGetName(getID());
    }
    }


    /**
     * Calculates the hash code value for a BaseObj.
     *
     * @return int
     */
    @Override
    public int hashCode() {
        return mID;
    }

    /**
     * Compare the current BaseObj with another BaseObj for equality.
     *
     * @param obj The object to check equality with.
     *
     * @return boolean
     */
    @Override
    public boolean equals(Object obj) {
        // Early-out check to see if both BaseObjs are actually the same
        if (this == obj)
            return true;

        if (getClass() != obj.getClass()) {
            return false;
        }

        BaseObj b = (BaseObj) obj;
        return mID == b.mID;
    }
}
}