You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Will be an annotation to suggest implementation of equals/hashCode in all
implementations of an interface (all subclasses of a class, including itself)?
It might be useful to reduce error caused by using the default
implementation of equals/hashCode methods.
(I am not sure whether it is useful to have an annotation only for concrete
implementations, and one another requiring them on both abstract and
concrete implementations too.)
Is might be also useful similar to toString methods.
Original issue reported on code.google.com by aborgabor on 23 Jun 2009 at 1:39
The text was updated successfully, but these errors were encountered:
It is very easy - declare equals/hashCode/toString in your interface, or if you
have
a class - override Object's ones with abstract. Children will either declare
your
methods, or won't compile.
earwin, I think the solution you mentioned with interfaces does not work with
eclipse's 1.6 compiler, and declaring the hashCode, equals (toString) methods as
abstract will require to have helper methods to access the state of the base
classes
in descendents, or an alternative implementation of hashCode, equals (toString)
accessible to descendent classes.
Original comment by aborgabor on 19 Oct 2009 at 11:45
Original issue reported on code.google.com by
aborgabor
on 23 Jun 2009 at 1:39The text was updated successfully, but these errors were encountered: