Skip to content
Snippets Groups Projects
Commit 063eb382 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

fix of failures: was again due to the EMF annoying thing of forcing...

fix of failures: was again due to the EMF annoying thing of forcing non-duplicates in function arguments
refs 2077
parent bbce93ce
Branches
Tags
No related merge requests found
......@@ -41,7 +41,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 5F67CC13C984B7BFAC47E80A481EA0EB
* @ConQAT.Rating YELLOW Hash: 333AA8802FB7E83D056CF1FDC8F0BA7B
*/
public class EcoreUtils {
......@@ -235,17 +235,10 @@ public class EcoreUtils {
(List<EObject>)eObject.eGet(eReference);
@SuppressWarnings("unchecked") List<EObject> target =
(List<EObject>)copyEObject.eGet(getTarget(eReference));
if(!(target instanceof AbstractEList<?>)) {
super.copyContainment(eReference, eObject, copyEObject);
return;
}
@SuppressWarnings("unchecked") AbstractEList<EObject> abstractTarget =
(AbstractEList<EObject>)copyEObject.eGet(getTarget(eReference));
if(source.isEmpty()) {
abstractTarget.clear();
target.clear();
} else {
// Here is the hack: we use addAllUnique instead of addAll!
abstractTarget.addAllUnique(copyAll(source));
addAll(target, copyAll(source));
}
} else {
EObject childEObject = (EObject)eObject.eGet(eReference);
......@@ -256,6 +249,25 @@ public class EcoreUtils {
}
}
/**
* Hacked "addAll" method to circumvent the removal of duplicate elements.
*
* In theory this should not be necessary: if a list requires non duplicate elements, then the
* default of removing these duplicates when adding to a list should be kept. The problem is
* that (since Kepler?) EMF forces us to set some lists as "unique" when we do not want it to
* (typically the arguments of a function in an expression). So since we do not have any other
* choice at the level of the meta-model, we have to hack. Here is the hack.
*/
public static <T extends EObject, U extends T> void addAll(List<T> l1, Collection<U> l2) {
if(l1 instanceof AbstractEList<?>) {
// Here is the hack: we use addAllUnique instead of addAll
((AbstractEList<T>)l1).addAllUnique(l2);
} else {
// In other cases we just revert to the standard behavior
l1.addAll(l2);
}
}
/**
* Returns a self-contained copy of the eObject.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment