Skip to content
Snippets Groups Projects
Commit 393167d8 authored by Simon Barner's avatar Simon Barner
Browse files

- Add replaceEObjectReferences()

refs 3219
parent 91ad96ba
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ CompositionUtils.java a2b1c7f4b1ae4d0783b4e170e432a9e02fc451fd GREEN ...@@ -2,7 +2,7 @@ CompositionUtils.java a2b1c7f4b1ae4d0783b4e170e432a9e02fc451fd GREEN
ConstraintsUtils.java 93ae55d9c4a2645a97bb4162f43eb00acbc94633 GREEN ConstraintsUtils.java 93ae55d9c4a2645a97bb4162f43eb00acbc94633 GREEN
EMFResourceUtils.java 01cddc68d7dd199191792d87f8256d6c52540856 GREEN EMFResourceUtils.java 01cddc68d7dd199191792d87f8256d6c52540856 GREEN
EcoreSerializerBase.java 63b879cb32a0981dc1fefaf33db098abe81fe520 GREEN EcoreSerializerBase.java 63b879cb32a0981dc1fefaf33db098abe81fe520 GREEN
EcoreUtils.java 008f4743d5092afb13c7f4cbbfcb83f1dc6b7721 GREEN EcoreUtils.java c191385af86ff630d1ad9daacb42751527db8744 YELLOW
ExtensionPointUtils.java e3ec0d396b0a88c040fd0117d4a369340d6099f4 GREEN ExtensionPointUtils.java e3ec0d396b0a88c040fd0117d4a369340d6099f4 GREEN
IdentifierUtils.java d074a0f40d0ace7c2dd4ec145f0c2d783fbe115d GREEN IdentifierUtils.java d074a0f40d0ace7c2dd4ec145f0c2d783fbe115d GREEN
JavaUtils.java 88bebee35226100989e118b272c766fa63f3c87c GREEN JavaUtils.java 88bebee35226100989e118b272c766fa63f3c87c GREEN
......
...@@ -18,6 +18,7 @@ package org.fortiss.tooling.kernel.utils; ...@@ -18,6 +18,7 @@ package org.fortiss.tooling.kernel.utils;
import static org.eclipse.emf.common.notify.Notification.EVENT_TYPE_COUNT; import static org.eclipse.emf.common.notify.Notification.EVENT_TYPE_COUNT;
import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents; import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents;
import static org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer; import static org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer;
import static org.eclipse.emf.ecore.util.EcoreUtil.replace;
import static org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer.find; import static org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer.find;
import java.util.Collection; import java.util.Collection;
...@@ -43,6 +44,7 @@ import org.eclipse.emf.ecore.EPackage; ...@@ -43,6 +44,7 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EPackage.Registry; import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.EcoreUtil;
...@@ -495,6 +497,22 @@ public class EcoreUtils { ...@@ -495,6 +497,22 @@ public class EcoreUtils {
return usages; return usages;
} }
/**
* Replaces all references to the {@link EObject}s contained in the key set of the given
* {@code objectMap} with the corresponding elements they are mapped to.
*
* @param eObjectMap
* Maps each old {@link EObject} to the corresponding new {@link EObject}
*/
public static void
replaceEObjectReferences(Map<? extends EObject, ? extends EObject> eObjectMap) {
for(EObject eObject : eObjectMap.keySet()) {
for(Setting setting : getAllReferences(eObject)) {
replace(setting, eObject, eObjectMap.get(eObject));
}
}
}
/** /**
* <p> * <p>
* Disables the notifications emitted by the given {@link EObject} and its children. * Disables the notifications emitted by the given {@link EObject} and its children.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment