Package cz.cvut.kbss.jopa.sessions
Class CloneBuilder
java.lang.Object
cz.cvut.kbss.jopa.sessions.CloneBuilder
Builds clones used in transactions for tracking changes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildClone
(Object original, CloneConfiguration cloneConfiguration) Builds clone of the given object.buildClone
(Object cloneOwner, Field clonedField, Object original, Descriptor descriptor) Builds clone of the given object.void
mergeChanges
(ObjectChangeSet changeSet) Merges the changes on clone into the original object.void
removeVisited
(Object instance, Descriptor descriptor) Removes the specified instance from the clone builder's visited entities cache.void
reset()
Resets the clone builder.
-
Constructor Details
-
CloneBuilder
-
-
Method Details
-
buildClone
Builds clone of the given object.- Parameters:
original
- ObjectcloneConfiguration
- Configuration for the cloning process- Returns:
- The clone
- Throws:
NullPointerException
- Iforiginal
isnull
-
buildClone
public Object buildClone(Object cloneOwner, Field clonedField, Object original, Descriptor descriptor) Builds clone of the given object.This method differs from
buildClone(Object, CloneConfiguration)
in that it accepts another argument which represents the owner of the built clone. This is useful in situations when we are cloning attributes directly, e.g. when lazily loading a field value.- Parameters:
cloneOwner
- The owner of the created cloneclonedField
- The field whose value is being clonedoriginal
- The original to clonedescriptor
- Entity descriptor- Returns:
- The clone
- Throws:
NullPointerException
- IfcloneOwner
,original
orcontextUri
isnull
-
mergeChanges
Merges the changes on clone into the original object.- Parameters:
changeSet
- Contains changes to merge
-
reset
public void reset()Resets the clone builder.Especially resets the visited objects cache to make sure all the clones are built from scratch and are not affected by the previously built ones.
-
removeVisited
Removes the specified instance from the clone builder's visited entities cache.- Parameters:
instance
- The instance to remove (original object).descriptor
- Instance descriptor
-