Thanks, Byron. I'd appreciate if you'd attach these absolutely useful
comments to a Jira issue to be created. Having said that, I guess we
both agree that it will be in the user's responsibility to provide the
adequate infrastructure in terms of cloning. All we (Castor) can do is
make proper use of thus infrastructure, and help the users to achieve
their goal.
Werner
Developer Dude wrote:
Just a few notes and some caution. I have implemented clone() on a lot of
POJOs and there are some patterns that I follow:
1) You don't have to bother with primitives or Strings - the default
behavior for Java objects covers those. Maybe all immutables too, I forget,
but definitely Strings.
2) You really have to know that the the object you are calling clone() on is
cloneable - a lot of classes aren't, in fact most aren't. I.E., it has to
implement Cloneable. Object has a protected clone() method, but does not
declare itself as Cloneable and that is correct; generally the best practice
is to start the implementation of the clone() method at the base of your
class heirarchy as each class should call the super.clone() method. If the
parent class isn't cloneable then you may have problems. Also, any members
must be cloneable or you will run into problems there too. There there are
collections. I have methods to perform deep copies on the collections we
have within classes, and this works okay for us because we have control over
all of the class heirarchy, but that isn't guaranteed in Castor.
There are some other idiosyncracies but that's the gist of it. I would think
implementation of a generated clone() method might be problematic unless the
developer was willing to tweak the implementation each time to make it
correct and/or accept something that may not compile.
-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 09, 2007 12:39 PM
To: [email protected]
Subject: Re: [castor-user] New feature request: generated clone method
Byron,
no, this is not available yet. How about raising a feature request at
http://jira.codehaus-org/nrowse/CASTOR
and attach the information provided in this email to the issue created ?
With some guideance from our side, would you be willoing to provide us with
an initial patch or work with us to get your ideas implemented/specified
fully ?
Regards
Werner
Phillips, Byron J wrote:
I'm currently using castor 0.9.6 and am interested in having castor
generate a clone method that, similar to the equals method, performs a
memberwise clone for each data member. For non-primitive type data
members, this clone method would be performed by calling that member's
clone method; for primitive types, the assignment operator would be used.
Is this capability already available in a later release of Castor?
I've reviewed the release notes, but didn't see anything like it.
Byron Phillips / LMTSS / 301-640-2283 / 870/2E20
/"When striving to get ahead of the game, ensure you are playing the
correct game." -- RabidAnt,_ Why, O Why!_/
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email