Skip to content
Snippets Groups Projects
Commit 645c4303 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Introduce updated `getAllReferences` method

* `getAllReferences` now returns the collection of all EObjects
referencing the given 'referencedEObject'
* The original `getAllReferences` method has been renamed to
`getAllReferencesSetting`

Issue-Ref: 3798
Issue-Url: https://af3-developer.fortiss.org/issues/3798



Signed-off-by: default avatarTiziano Munaro <munaro@fortiss.org>
parent 923eba9d
No related branches found
No related tags found
No related merge requests found
......@@ -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 df46cf243f57835936be5a6e4e892f9b2fc29f7e YELLOW
ExtensionPointUtils.java 7ce63242b49eb9a7cd4eaadd223f5ebce1dfd75b GREEN
HierarchicalNameComparator.java 6face1b673126701a0721af48ead2f9766c17d46 GREEN
IdentifierUtils.java fff43dc4e84cdd89c3ece4f5d9d89aec4b0749c2 GREEN
......
......@@ -659,11 +659,12 @@ 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
* @return A {@link Collection}, containing all <EStructuralFeature.Setting>, which are
* references
* to 'referencedEObject'.
*/
public static Collection<EStructuralFeature.Setting>
getAllReferences(EObject referencedEObject) {
getAllReferencesSetting(EObject referencedEObject) {
EObject rootEObject = getRootContainer(referencedEObject);
Resource resource = rootEObject.eResource();
......@@ -678,6 +679,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 +702,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));
}
}
......
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