I have an arbitrary object tagged as Serializable. It has various mutable child objects representing monetary amounts, collections etc. I want to be able to clone this object so if the user modifies it and then reverts their action, I can just replace the clone with a fresh clone.
That implies I need a deep copy because I don't want the users changes to child objects (e.g. adding / inserting items from the collection) appearing on the original.
The objects don't implement Cloneable and as they're autogenerated I can't add such a method either.
Short of painfully handwriting a deep clone is there anyway to accomplish the same in GWT? If this were Java I could consider serializing the object to a byte array stream and deserializing a fresh copy.
I can't do that in GWT. Potentially I could harness RPC because the object is sent to a servlet later. I just don't know if that is easy to do.
Anyone know a simple way I can do a deep copy?