Skip to content
Snippets Groups Projects
Commit 94034458 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

A first baseline of model-checking of simple code specifications.

refs 411
parent e1669056
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,9 @@ import java.util.List;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* Utility methods for dealing with .ecore models. These methods should be used
......@@ -127,4 +130,28 @@ public class EcoreUtils {
return (T) sourceElement;
return null;
}
/**
* For a given EObject recursively returns all its children that have a
* certain type.
*
* @param parent
* - the parent EObject
* @param type
* - the type
* @return a list of children
*/
@SuppressWarnings("unchecked")
public static <S> EList<S> getChildrenWithType(EObject parent, Class<S> type) {
EList<S> children = new BasicEList<S>();
TreeIterator<EObject> content = EcoreUtil.getAllContents(parent, true);
while (content.hasNext()) {
EObject child = content.next();
if (type.isAssignableFrom(child.getClass())) {
children.add((S) child);
}
}
return 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