pardom/ActiveAndroid — pull request #104 by vsigler (2013-08-10 09:28:04+00:00)
Title: Equals() should be type safe, null-aware and there hashcode() should be overridden

When playing around with ActiveAndroid I found weird behavior of the Model.equals() method.

* For two new blank models, equals would not consider them equal.
* Equals would throw ClassCastException when compared to anything else than another model.
* Equals against null throws NullPointerException

After looking at the equals method, it does not check type or null/notnull of the other object. Also, once a model has null id (not yet saved), it is automatically not equal to anything, which I also see as a bug. There is also a missing hashcode override, so models cannot be used in e.g. hash sets.

The proposed changes fix these problems - overridden hashcode, type safe and null-aware equals and null id does not automatically mean not equal to anything. I've also added a test for this behavior.