Commit f925951e authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '3798' into 'master'

Introduce updated `getAllReferences` method

See merge request !71
parents 923eba9d f05543f0
......@@ -2,7 +2,7 @@ CompositionUtils.java 34c0a191bd0fb4176c94b4d61abb5c88a679d5e8 GREEN
ConstraintsUtils.java 0f8be020f2ca4bb08931c32452163c04a28e30ce GREEN
EMFResourceUtils.java 979d0e1f4f66a2b3e715d2da0ebef6493f547fd7 GREEN
EcoreSerializerBase.java 0a0c2969d793d2e68094c55c8f7b0a662ef6e5d5 GREEN
EcoreUtils.java af30c39f36db02322c0a805bfc67ffeeb157c52b GREEN
EcoreUtils.java 18416b5c214410a02eb35596fd807a1cc27d6b35 GREEN
ExtensionPointUtils.java 7ce63242b49eb9a7cd4eaadd223f5ebce1dfd75b GREEN
HierarchicalNameComparator.java 6face1b673126701a0721af48ead2f9766c17d46 GREEN
IdentifierUtils.java fff43dc4e84cdd89c3ece4f5d9d89aec4b0749c2 GREEN
......
......@@ -659,11 +659,11 @@ public class EcoreUtils {
*
* @param referencedEObject
* The {@link EObject}, to which all references are supposed to be retrieved.
* @return A {@link Collection}, containg all EStructuralFeature.Setting>, which are references
* to 'referencedEObject'.
* @return A {@link Collection} containing all <EStructuralFeature.Setting>, which are
* references to 'referencedEObject'.
*/
public static Collection<EStructuralFeature.Setting>
getAllReferences(EObject referencedEObject) {
private static Collection<EStructuralFeature.Setting>
getAllReferencesSetting(EObject referencedEObject) {
EObject rootEObject = getRootContainer(referencedEObject);
Resource resource = rootEObject.eResource();
......@@ -678,6 +678,19 @@ public class EcoreUtils {
return usages;
}
/**
* Retrieves all {@link EObject}s which reference the given 'referencedEObject'.
*
* @param referencedEObject
* The {@link EObject}, to which all references are supposed to be retrieved.
* @return A {@link Collection} containing the {@link EObject}s referencing the given
* 'referencedEObject'.
*/
public static Collection<EObject> getAllReferences(EObject referencedEObject) {
return getAllReferencesSetting(referencedEObject).stream().map(s -> s.getEObject())
.collect(toList());
}
/**
* 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.
......@@ -688,7 +701,7 @@ public class EcoreUtils {
public static void
replaceEObjectReferences(Map<? extends EObject, ? extends EObject> eObjectMap) {
for(EObject eObject : eObjectMap.keySet()) {
for(Setting setting : getAllReferences(eObject)) {
for(Setting setting : getAllReferencesSetting(eObject)) {
replace(setting, eObject, eObjectMap.get(eObject));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment