dkpro / dkpro-statistics

DKPro Statistics
https://dkpro.github.io/dkpro-statistics
Apache License 2.0
12 stars 4 forks source link

SetAnnotation.equals() should not use toString() to test equality #20

Open logological opened 9 years ago

logological commented 9 years ago

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?