@Override public <T> Collection<T> copyAll(Collection<? extends T> eObjects) { Collection<T> result = new ArrayList<T>(eObjects.size()); for (Object object : eObjects) { @SuppressWarnings("unchecked") T copy = (T) copy((EObject) object); result.add(copy); for (TreeIterator<EObject> eAllContents = ((EObject) object) .eAllContents(); eAllContents.hasNext();) { EObject childEObject = eAllContents.next(); if (childEObject instanceof Element) { @SuppressWarnings("unchecked") Collection<T> copies = (Collection<T>) super .copyAll(((Element) childEObject) .getStereotypeApplications()); result.addAll(copies); } } } return result; }
Collection<EObject> newObjectsToAttach = copier.copyAll(objectsToDetach); copier.copyReferences();
Collection<EObject> newObjectsToAttach = copier.copyAll(objectsToDetach); copier.copyReferences();
copier.copyAll(propertyFeatureList); copier.copyReferences();
copier.copyAll(propertyFeatureList); copier.copyReferences();
/** * 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. * @param eReference the feature to copy. * @param eObject the object from which to copy. * @param copyEObject the object to copy to. */ protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) { if (eObject.eIsSet(eReference)) { EStructuralFeature.Setting setting = getTarget(eReference, eObject, copyEObject); if (setting != null) { Object value = eObject.eGet(eReference); if (eReference.isMany()) { @SuppressWarnings("unchecked") List<EObject> target = (List<EObject>)value; setting.set(copyAll(target)); } else { setting.set(copy((EObject)value)); } } } }
/** * 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. * @param eReference the feature to copy. * @param eObject the object from which to copy. * @param copyEObject the object to copy to. */ protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) { if (eObject.eIsSet(eReference)) { EStructuralFeature.Setting setting = getTarget(eReference, eObject, copyEObject); if (setting != null) { Object value = eObject.eGet(eReference); if (eReference.isMany()) { @SuppressWarnings("unchecked") List<EObject> target = (List<EObject>)value; setting.set(copyAll(target)); } else { setting.set(copy((EObject)value)); } } } }
/** * copies contents of a resource set into a new one */ public static <T extends ResourceSet> T clone(T target, ResourceSet source) { EList<Resource> resources = source.getResources(); EcoreUtil.Copier copier = new EcoreUtil.Copier(); for (Resource resource : resources) { Resource resource2 = target.createResource(resource.getURI()); resource2.getContents().addAll(copier.copyAll(resource.getContents())); } copier.copyReferences(); return target; }
/** * Returns a collection of the self-contained copies of each {@link EObject} in eObjects. * @param eObjects the collection of objects to copy. * @return the collection of copies. * @see Copier */ public static <T> Collection<T> copyAll(Collection<? extends T> eObjects) { Copier copier = new Copier(); Collection<T> result = copier.copyAll(eObjects); copier.copyReferences(); return result; }
/** * Returns a collection of the self-contained copies of each {@link EObject} in eObjects. * @param eObjects the collection of objects to copy. * @return the collection of copies. * @see Copier */ public static <T> Collection<T> copyAll(Collection<? extends T> eObjects) { Copier copier = new Copier(); Collection<T> result = copier.copyAll(eObjects); copier.copyReferences(); return result; }