The SetAnnotation class has an implementation of equals() which tests equality by converting the operands to Strings. I don't think this is a good idea. Users may be comparing annotations represented by arbitrary objects, and those objects may implement toString() methods which return the same text even when the objects are different. (Or perhaps the objects don't even have their own implementation of toString(), causing Java to output distinct numeric references even when the objects' actual values are equivalent.)
Unless I'm missing something important here, shouldn't equals() simply be eliminated and the class allowed to use the parent HashSet implementation?
The
SetAnnotation
class has an implementation ofequals()
which tests equality by converting the operands toString
s. I don't think this is a good idea. Users may be comparing annotations represented by arbitrary objects, and those objects may implementtoString()
methods which return the same text even when the objects are different. (Or perhaps the objects don't even have their own implementation oftoString()
, causing Java to output distinct numeric references even when the objects' actual values are equivalent.)Unless I'm missing something important here, shouldn't
equals()
simply be eliminated and the class allowed to use the parentHashSet
implementation?