ComparableMeasurement fails to compare
ComparableMeasurement.compareTo(...)
violates the contract of compareTo(...)
because it is not commutative. Namely if two instances are copies of each other then a.compareTo(b)
and b.compareTo(a)
both return -1
, indicating that a
is both before and after b
, a logical impossibility. The comment in the code indicates it is trying to impose some sort of order, but it fails to do even that.
Suggestion: next try the identity hash code for the two objects, then return zero if they really are equal.