You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In essence, it does not accommodate other implementations of the Set interface, such that a HashSet and an ObjectHashSet of the same contents are not equal. This blocks the adoption of ObjectHashSet as a drop in replacement. Happy to provide a PR if we agree this is desirable to be fixed.
The text was updated successfully, but these errors were encountered:
Further notes from Collection::equals:
The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)"
From the Set::equals javadoc:
"Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the set interface."
@RichardWarburton and I spent some time on the map implementations so they work for equals and hashCode but the set implementations have not had the same love.
In essence, it does not accommodate other implementations of the Set interface, such that a HashSet and an ObjectHashSet of the same contents are not equal. This blocks the adoption of ObjectHashSet as a drop in replacement. Happy to provide a PR if we agree this is desirable to be fixed.
The text was updated successfully, but these errors were encountered: