Interface CopyPolicy
- All Superinterfaces:
Cloneable
,Serializable
- All Known Implementing Classes:
AbstractCopyPolicy
,CloneCopyPolicy
,InstantiationCopyPolicy
,PersistenceEntityCopyPolicy
Purpose: Allows customization of how an object is cloned. An implementer of CopyPolicy can be set on a descriptor to provide special cloning routine for how an object is cloned in a unit of work. By default the InstantiationCopyPolicy is used which creates a new instance of the class to be copied into. The CloneCopyPolicy can also be used that uses a clone method in the object to clone the object. When a clone method is used it avoid the requirement of having to copy over each of the direct attributes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuildClone
(Object object, Session session) Return a shallow clone of the object for usage with object copying, or unit of work backup cloning.boolean
Return if this copy policy creates a new instance, vs a clone.buildWorkingCopyClone
(Object object, Session session) Return a shallow clone of the object for usage with the unit of work working copy.buildWorkingCopyCloneFromRow
(Record row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow) Return an instance with the primary key set from the row, used for building a working copy during a unit of work transactional read.clone()
Clone the CopyPolicy.void
initialize
(Session session) Allow for any initialization or validation required.void
setDescriptor
(ClassDescriptor descriptor) Set the descriptor.
-
Method Details
-
buildClone
Return a shallow clone of the object for usage with object copying, or unit of work backup cloning.- Throws:
DescriptorException
-
buildWorkingCopyClone
Return a shallow clone of the object for usage with the unit of work working copy.- Throws:
DescriptorException
-
buildWorkingCopyCloneFromRow
Object buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow) throws DescriptorException Return an instance with the primary key set from the row, used for building a working copy during a unit of work transactional read.- Throws:
DescriptorException
-
clone
Object clone()Clone the CopyPolicy. -
initialize
Allow for any initialization or validation required.- Throws:
DescriptorException
-
setDescriptor
Set the descriptor. -
buildsNewInstance
boolean buildsNewInstance()Return if this copy policy creates a new instance, vs a clone.
-