Stream: hapi
Topic: compareTo() and hashCode()
Keith Boone (Oct 27 2016 at 23:43):
One of my developers noted that two Codings which were identical were not being treated in that fashion. This should be a simple fix.
James Agnew (Oct 28 2016 at 18:17):
do you mean equals
? if so, this was a quasi-deliberate choice.. it's a bit ambiguous what equals means in the context of a composite object. Do we consider extensions? Or the object's ID? Or the target if it's a reference? Or the version number?
We used to compare the fields but not the extensions and base the results of equals on that.. but that's an arbitrary choice. Now there is equalsShallow
and equalsDeep
which gives to potential implementations depending on the semantics you're after...
It's not clear to me how compareTo
would work in the context of a coding though
Last updated: Apr 12 2022 at 19:14 UTC