I?d like to implement the cloning in a class, say Father, and implement it in some way that descendants of the Father class didn?t need to (re)implement it. I?ve been venturing through the java.lang.reflect package to find some way of performing a deep cloning by calling the clone method through a Method class, but I guess that wouldn?t suffice. I know that if I implement the clone method in Father in traditional way, I?ll get a "shallow clone". But that?s not enough. Does anyone have any idea?
I remember reading about this subject in Josh Bloch's Effective Java book. I don't have it with me and I don't remember all the salient details, but maybe you can find a copy of the book nearby...
Should the father be capable of providing a cloning for all its children in a transparent way... or even better have a generic cloning factory that would do a deep cloning of any Object given in reference ? In both case, I'd like to see the answer 'coze it's a problem that very rarely needs to be solved... but then we usually need it quick :-))