Method Detail

clone

This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T) to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T) to copy any reference fields.

Fields that are aggregate parts of the object should always be copied.
A referenced object is an aggregate if properties or methods on the object
being copied can modify the externally-visible value of the referenced object.

If the semantics of the referenced object require that it have a single parent,
owner, context, etc., and the object being copied is that parent, owner, or context,
then the referenced object should always be copied.

If one of these exceptions applies, the CopyContext should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T) to update the reference. If CopyContext.updateReference(T) returns
the original object (that is, if the reference some field is equal to the reference of the same field of another instance))
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.