This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Generic clone/equals Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generic clone/equals Methods" Watch "Generic clone/equals Methods" New topic

Generic clone/equals Methods

Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

I have implemented the following generic copy/equals method in our base Value Object. Any value object extending from the base class will not need to provide for the same.

I am contemplating making them final, coz I do not want any extending classes to override the implementation. But it then takes away the freedom providing alternate behavior.

Can anyone tell me, if this is the right way to go about and not make the methods final in the base VO?

The only reason I see for not making them final is as above and do we really have reasons for implementing different clone/equals in a project. I belive the behaviour for clone or equals is a project standard and we either have deep/shallow copies/equals.

Please let me know if otherwise.
[ March 22, 2007: Message edited by: Devesh H Rao ]
jQuery in Action, 2nd edition
subject: Generic clone/equals Methods