T
Tim Tyler
Object.clone() does a shallow copy.
Nine times out of ten I want a deep copy.
I'm fed up with writing my own deep copy code for each class.
What I want is never to have to write deep copy clone methods again.
Has anyone got some generic Object deep copy code - that will deep
copy an arbitrary object - using reflection?
I know that some objects might in principle require bizzare
constructor or factory calls to copy.
The hoped-for deep copy code is welcome to expect primitives, objects
with clone methods - or collections or arrays of the above - and
is welcome to throw some CloneChallengedException if it finds things
are beyond its scope.
When you're done with that I'll take another method that calcutates
hash codes - by a combination of feeding leaf primitives through
a CRC/Cr# - and calling object hash code methods recursively, and
#ing the results together ;-) ;-)
Nine times out of ten I want a deep copy.
I'm fed up with writing my own deep copy code for each class.
What I want is never to have to write deep copy clone methods again.
Has anyone got some generic Object deep copy code - that will deep
copy an arbitrary object - using reflection?
I know that some objects might in principle require bizzare
constructor or factory calls to copy.
The hoped-for deep copy code is welcome to expect primitives, objects
with clone methods - or collections or arrays of the above - and
is welcome to throw some CloneChallengedException if it finds things
are beyond its scope.
When you're done with that I'll take another method that calcutates
hash codes - by a combination of feeding leaf primitives through
a CRC/Cr# - and calling object hash code methods recursively, and
#ing the results together ;-) ;-)