java.lang.Object
org.eclipse.persistence.descriptors.copying.AbstractCopyPolicy
org.eclipse.persistence.descriptors.copying.CloneCopyPolicy
- All Implemented Interfaces:
Serializable,Cloneable,CopyPolicy
Purpose: Allows a clone of an object to be created with a method that returns the cloned object.
It is possible to define methods for two types of clones
methodNamecan be set to define the method EclipseLink uses to clone objects for it's own internal use. The objects created by this method will not be visible to the user, and instead used as a basis for comparison when a DeferredChangeDetectionPolicy used. This method will also be in place of theworkingCopyMethodif it is not providedworkingCopyMethodthis method is used to create the clone that is returned to the user when anObjectis registered in a UnitOfWork
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Methodprotected StringAllow for clone method to be specified.protected Methodprotected StringFields inherited from class org.eclipse.persistence.descriptors.copying.AbstractCopyPolicy
descriptor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildClone(Object domainObject, Session session) Clone through calling theclonemethod.booleanReturn false as a shallow clone is returned, not a new instance.buildWorkingCopyClone(Object domainObject, Session session) Clone through theworkingCopyClonemethod, or if not specified theclonemethod.buildWorkingCopyCloneFromRow(DataRecord row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow) Create a new instance, unless aworkingCopyClonemethod is specified, then build a new instance and clone it.protected MethodReturn the clone method.Return the clone method name.protected MethodReturn theworkingCopyClonemethod.Return theworkingCopyClonemethod name.voidinitialize(Session session) Validate and build the methods.protected voidSet the clone method.voidsetMethodName(String methodName) Set the clone method name.protected voidsetWorkingCopyMethod(Method method) Set theworkingCopyClonemethod.voidsetWorkingCopyMethodName(String methodName) Set theworkingCopyClonemethod name.toString()Methods inherited from class org.eclipse.persistence.descriptors.copying.AbstractCopyPolicy
clone, getDescriptor, setDescriptor
-
Field Details
-
methodName
Allow for clone method to be specified. -
workingCopyMethodName
-
method
-
workingCopyMethod
-
-
Constructor Details
-
CloneCopyPolicy
public CloneCopyPolicy()
-
-
Method Details
-
buildClone
Clone through calling theclonemethod.- Specified by:
buildClonein interfaceCopyPolicy- Specified by:
buildClonein classAbstractCopyPolicy- Throws:
DescriptorException
-
buildWorkingCopyClone
public Object buildWorkingCopyClone(Object domainObject, Session session) throws DescriptorException Clone through theworkingCopyClonemethod, or if not specified theclonemethod.- Specified by:
buildWorkingCopyClonein interfaceCopyPolicy- Overrides:
buildWorkingCopyClonein classAbstractCopyPolicy- Throws:
DescriptorException
-
buildWorkingCopyCloneFromRow
public Object buildWorkingCopyCloneFromRow(DataRecord row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow) throws DescriptorException Create a new instance, unless aworkingCopyClonemethod is specified, then build a new instance and clone it.- Specified by:
buildWorkingCopyCloneFromRowin interfaceCopyPolicy- Overrides:
buildWorkingCopyCloneFromRowin classAbstractCopyPolicy- Throws:
DescriptorException
-
getMethod
Return the clone method. -
getMethodName
Return the clone method name. -
getWorkingCopyMethod
Return theworkingCopyClonemethod. This is used to clone within a unit of work. -
getWorkingCopyMethodName
Return theworkingCopyClonemethod name. This is used to clone within a unit of work. -
initialize
Validate and build the methods.- Specified by:
initializein interfaceCopyPolicy- Overrides:
initializein classAbstractCopyPolicy- Throws:
DescriptorException
-
setMethod
Set the clone method. -
setMethodName
Set the clone method name. -
setWorkingCopyMethod
Set theworkingCopyClonemethod. This is used to clone within a unit of work. -
setWorkingCopyMethodName
Set theworkingCopyClonemethod name. This is used to clone within a unit of work. -
buildsNewInstance
public boolean buildsNewInstance()Return false as a shallow clone is returned, not a new instance. -
toString
- Overrides:
toStringin classAbstractCopyPolicy
-