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

Commit d54f3f41 authored by Stephen Hines's avatar Stephen Hines Committed by Android (Google) Code Review
Browse files

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

parents fe930104 705d2ea6
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -134,5 +134,35 @@ public class BaseObj {
        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;
    }
}