Package com.nomagic.magicdraw.uml2.util
Class UMLCopier
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject>
-
- org.eclipse.emf.ecore.util.EcoreUtil.Copier
-
- com.nomagic.magicdraw.uml2.util.UMLCopier
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject>
public class UMLCopier extends org.eclipse.emf.ecore.util.EcoreUtil.Copier
Utility class that should be used to copy UML model objects.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
UMLCopier.IndexTracker
-
Constructor Summary
Constructors Constructor Description UMLCopier()
Creates an instance.UMLCopier(boolean resolveProxies)
Creates an instance that resolves proxies or not as specified.UMLCopier(boolean resolveProxies, boolean useOriginalReferences)
Creates an instance that resolves proxies or not and uses non-copied references or not as specified.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Boolean
addOrMoveOrNone(org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.util.InternalEList<org.eclipse.emf.ecore.EObject> targetList, org.eclipse.emf.ecore.EReference eOpposite, int index, org.eclipse.emf.ecore.EObject copyReferencedEObject)
private void
addToTargetWhenBidirectional(org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.util.InternalEList<org.eclipse.emf.ecore.EObject> targetList, org.eclipse.emf.ecore.EReference eOpposite, int index, org.eclipse.emf.ecore.EObject copyReferencedEObject, UMLCopier.IndexTracker indexTracker)
org.eclipse.emf.ecore.EObject
copy(org.eclipse.emf.ecore.EObject eObject)
Returns a copy of the given eObject.protected void
copyContainment(org.eclipse.emf.ecore.EReference eReference, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyEObject)
Called to handle the copying of a containment feature; this adds a list of copies or sets a single copy as appropriate for the multiplicity.protected void
copyReference(org.eclipse.emf.ecore.EReference eReference, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyEObject)
Called to handle the copying of a cross reference; this adds values or sets a single value as appropriate for the multiplicity while omitting any bidirectional reference that isn't in the copy map.void
copyReferences()
Hooks up cross references; it delegates tocopyReference
.-
Methods inherited from class org.eclipse.emf.ecore.util.EcoreUtil.Copier
copyAll, copyAttribute, copyAttributeValue, copyFeatureMap, copyProxyURI, createCopy, getTarget, getTarget, getTarget, getTarget
-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Constructor Detail
-
UMLCopier
public UMLCopier()
Creates an instance.
-
UMLCopier
public UMLCopier(boolean resolveProxies)
Creates an instance that resolves proxies or not as specified.- Parameters:
resolveProxies
- whether proxies should be resolved while copying.
-
UMLCopier
public UMLCopier(boolean resolveProxies, boolean useOriginalReferences)
Creates an instance that resolves proxies or not and uses non-copied references or not as specified.- Parameters:
resolveProxies
- whether proxies should be resolved while copying.useOriginalReferences
- whether non-copied references should be used while copying.
-
-
Method Detail
-
copy
public org.eclipse.emf.ecore.EObject copy(org.eclipse.emf.ecore.EObject eObject)
Returns a copy of the given eObject.- Overrides:
copy
in classorg.eclipse.emf.ecore.util.EcoreUtil.Copier
- Parameters:
eObject
- the object to copy.- Returns:
- the copy.
-
copyReferences
public void copyReferences()
Hooks up cross references; it delegates tocopyReference
.- Overrides:
copyReferences
in classorg.eclipse.emf.ecore.util.EcoreUtil.Copier
-
copyContainment
protected void copyContainment(org.eclipse.emf.ecore.EReference eReference, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyEObject)
Called to handle the copying of a containment feature; this adds a list of copies or sets a single copy as appropriate for the multiplicity.- Overrides:
copyContainment
in classorg.eclipse.emf.ecore.util.EcoreUtil.Copier
- Parameters:
eReference
- the feature to copy.eObject
- the object from which to copy.copyEObject
- the object to copy to.
-
copyReference
protected void copyReference(org.eclipse.emf.ecore.EReference eReference, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject copyEObject)
Called to handle the copying of a cross reference; this adds values or sets a single value as appropriate for the multiplicity while omitting any bidirectional reference that isn't in the copy map.- Overrides:
copyReference
in classorg.eclipse.emf.ecore.util.EcoreUtil.Copier
- Parameters:
eReference
- the reference to copy.eObject
- the object from which to copy.copyEObject
- the object to copy to.
-
addToTargetWhenBidirectional
private void addToTargetWhenBidirectional(org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.util.InternalEList<org.eclipse.emf.ecore.EObject> targetList, org.eclipse.emf.ecore.EReference eOpposite, int index, org.eclipse.emf.ecore.EObject copyReferencedEObject, UMLCopier.IndexTracker indexTracker)
-
addOrMoveOrNone
private java.lang.Boolean addOrMoveOrNone(org.eclipse.emf.ecore.EObject copyEObject, org.eclipse.emf.ecore.util.InternalEList<org.eclipse.emf.ecore.EObject> targetList, org.eclipse.emf.ecore.EReference eOpposite, int index, org.eclipse.emf.ecore.EObject copyReferencedEObject)
-
-