Community
Participate
Working Groups
hi.. in my attempt to decipher why TaskRepository does not persist well in my view i noticed that it's hash code implementation differs from the equels one, meaning the hashcode only refers to the connector kind attribute while equels refers to both connector kind AND url. i saw no documentation, explaining this , which means the objects with the same hashcode may not be equel
I believe the implementation is correct. Please take a look at the contract for hashCode(). Basically if equals returns true for two Objects, the value returned by hashCode() must also be the same. The implementation in TaskRepository meets that contract. If two objects have the same hashCode() it is not guaranteed however that they are equal. In the case of TaskRepository it is implemented this way since the repository URL is mutable. Not hashing over the URL allows storing of TaskRepository objects in hash tables without having to worry about modifications to the objects.