Class CopyState
This class keeps tracks of which objects have already been copied when copying objects between transactions.
It also supports assigning different object ID's to objects as they are copied into the destination transaction.
Instances are not thread safe.
-
Constructor Summary
ConstructorsConstructorDescriptionCopyState(boolean suppressNotifications) Simple constructor.Copy constructor.Remapping constructor.Primary constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the object ID for the copy of the given source object.Get the mapping from object ID in the source transaction to object ID to use in the destination transaction.booleanDetermine if an object has been marked as copied.booleanbooleanmarkCopied(ObjId srcId) Determine if an object has already been copied, and if not mark it so.
-
Constructor Details
-
CopyState
public CopyState(boolean suppressNotifications) Simple constructor.No object ID's will be remapped.
Equivalent to:
CopyState(new ObjIdSet(), null, suppressNotifications).- Parameters:
suppressNotifications- true to suppress create and change notifications, otherwise false
-
CopyState
Remapping constructor.Equivalent to:
CopyState(new ObjIdSet(), objectIdMap, boolean suppressNotifications).- Parameters:
objectIdMap- mapping from source object ID to destination object IDsuppressNotifications- true to suppress create and change notifications, otherwise false- Throws:
IllegalArgumentException- ifobjectIdMapis null
-
CopyState
Primary constructor.Objects whose object ID's are in
copiedwill not be copied.Otherwise, copied objects will have their object ID's remapped based on
objectIdMap:- If an object's ID does not exist in
objectIdMap, then the same ID is used for the copy - If an object's ID is mapped to a non-null value in
objectIdMap, then that ID is used for the copy - Otherwise, a new, unused ID is allocated for the copy, and
objectIdMapis updated if/when that occurs
- Parameters:
copied- the ID's of objects that have already been copiedobjectIdMap- optional mapping from source object ID to remapped destination object IDsuppressNotifications- true to suppress create and change notifications, otherwise false- Throws:
IllegalArgumentException- if either parameter is null
- If an object's ID does not exist in
-
CopyState
Copy constructor.- Parameters:
original- instance to copy
-
-
Method Details
-
markCopied
Determine if an object has already been copied, and if not mark it so.- Parameters:
srcId- object ID (in the source transaction) of the object being copied- Returns:
- true if
srcIdwas not previously marked copied, otherwise false - Throws:
IllegalArgumentException- ifsrcIdis null
-
isCopied
Determine if an object has been marked as copied.- Parameters:
srcId- object ID (in the source transaction) of the object being copied- Returns:
- true if
srcIdhas been marked copied, otherwise false - Throws:
IllegalArgumentException- ifsrcIdis null
-
isSuppressNotifications
public boolean isSuppressNotifications() -
getObjectIdMap
Get the mapping from object ID in the source transaction to object ID to use in the destination transaction.This method returns the
objectIdMapparameter given to the constructor.- Returns:
- mapping from source transaction object ID to destination transaction object ID
-
getDestId
Get the object ID for the copy of the given source object.This assumes the object has already been copied, so its new, remapped object ID (if any) has already been updated in the object ID map. This can be verified using
isCopied().- Parameters:
srcId- source transaction object ID of an object that has been copied- Returns:
- destination transaction object ID corresponding to
srcId, never null - Throws:
IllegalArgumentException- ifsrcIdis null
-