Module io.github.sugarcubes.cloner
Package io.github.sugarcubes.cloner
Class TwoPhaseObjectCopier<T>
java.lang.Object
io.github.sugarcubes.cloner.TwoPhaseObjectCopier<T>
- All Implemented Interfaces:
ObjectCopier<T>
Two-phase copier.
-
Field Summary
Fields inherited from interface io.github.sugarcubes.cloner.ObjectCopier
CLONEABLE, COPYABLE, NOOP, NULL, OBJECT_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract TThe first phase of copying.copy(T original, CopyContext context) Creates a copy of the original object.abstract voiddeepCopy(T original, T clone, CopyContext context) The second phase of copying, copies the inner state from the original object into the clone.
-
Constructor Details
-
TwoPhaseObjectCopier
public TwoPhaseObjectCopier()
-
-
Method Details
-
copy
Description copied from interface:ObjectCopierCreates a copy of the original object. The implementation MUST callCopyContext.register(Object)method.- Specified by:
copyin interfaceObjectCopier<T>- Parameters:
original- original objectcontext- copying context ornullif the copier is trivial- Returns:
- copy result
- Throws:
Exception- if something went wrong
-
allocate
The first phase of copying. Creates an "empty" copy of the original object.- Parameters:
original- original object- Returns:
- clone
- Throws:
Exception- if something went wrong
-
deepCopy
The second phase of copying, copies the inner state from the original object into the clone.- Parameters:
original- original objectclone- clonecontext- copying context- Throws:
Exception- if something went wrong
-