Jesse Eichar a écrit :
I agree with you for the most part Martin. But if you look at some
implementations of equals, such as java.util.AbstractList, you will find
that it checks only that the object implements the interface and only
uses public methods to determine equality.
Yes, but they can do that because the equals(...) behavior for a List is
part of the specification. I mean, the java.util.List interface explains
exactly how the equals(...) method must behave for all java.util.List
implementations, including java.util.AbstractList:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#equals(java.lang.Object)
My point was:
- If we want to check for interface, then the *interface* should have
an equals(...) method with a javadoc that explain exactly how the
comparaison must be done for all implementations of that interface.
This is what Sun do for collections like List and Set.
- When the equals(...) behavior is not part of the specification,
then looking for implementation is just a conservative approach
for making sure that symmetry is enforced.
Just relying on public methods to determine equality is not enough. Look
for example at java.util.Collection: does the order of elements matter?
Element order matter if the collection is actually a java.util.List, but
doesn't matter (and should be ignored) if the collection is actually a
java.util.Set. This kind of details must be part of the specification of
the equals(...) method in interfaces, if we want to look for interfaces
only in equals(...).
I'm not against checking for interfaces in the equals(...) method. I
just said that if we want to do so, we shoud add an equals(...) method
in interfaces and explain there what this method should compare exactly
for all implementations.
Martin.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel