M
Michael Strorm
Hi,
I have a class which provides several definitions of equality.
equals() uses a particular definition depending on a value set via the
(static) method Classname.setEqualityMethod(VALUE).
It doesn't take a genius to see that this is very error-prone (not
thread-safe, hard to keep track of the current equalityMethod set). I
suspected it would come back and bite me in a horrible way, and to cut
a long story short, it did.
Well, it seems I can define comparators for collections, but not
equality. Is there a trivial solution to this, and why was it done
this way?
I've heard that it should be possible to work round this by
implementing your own collection, but this sounds like overkill to me.
My code is bloated and badly-designed enough as it is.
Any help appreciated, thank you.
- MS
I have a class which provides several definitions of equality.
equals() uses a particular definition depending on a value set via the
(static) method Classname.setEqualityMethod(VALUE).
It doesn't take a genius to see that this is very error-prone (not
thread-safe, hard to keep track of the current equalityMethod set). I
suspected it would come back and bite me in a horrible way, and to cut
a long story short, it did.
Well, it seems I can define comparators for collections, but not
equality. Is there a trivial solution to this, and why was it done
this way?
I've heard that it should be possible to work round this by
implementing your own collection, but this sounds like overkill to me.
My code is bloated and badly-designed enough as it is.
Any help appreciated, thank you.
- MS