Skip to content
Snippets Groups Projects
Commit 4a888833 authored by Luca Cristoforetti's avatar Luca Cristoforetti
Browse files

Add a new method to retrieve classes from package

parent 792a4890
No related branches found
No related tags found
No related merge requests found
......@@ -4182,6 +4182,7 @@ public class EntityUtil {
return null;
}
@SuppressWarnings("unchecked")
public Collection<Enumeration> getAllEnumeratives(Package packageElement) throws Exception {
return (Collection<Enumeration>) EObjectUtil.getAllElements(UMLPackage.eINSTANCE.getEnumeration(),
packageElement);
......@@ -4197,6 +4198,13 @@ public class EntityUtil {
throw new Exception("Element does not exist.");
}
/**
* Returns all the classes in the model.
* <p> BEWARE: all the classes, not only the classes in the given package
* @param packageElement
* @return
* @throws Exception
*/
public Collection<Class> getAllClasses(Package packageElement) throws Exception {
Collection<Class> classElements = null;
if (packageElement != null) {
......@@ -4220,4 +4228,30 @@ public class EntityUtil {
}
return result;
}
/**
* Returns the Class elements directly contained in a package.
* @param pkg the Package
* @return the Class children
*/
public Collection<Class> getPackageClasses(Package pkg) throws Exception {
Collection<Class> classElements = null;
if (pkg != null) {
Collection<Element> ownedElements = pkg.getOwnedElements();
if (ownedElements != null) {
classElements = getClasses(ownedElements);
}
return classElements;
}
throw new Exception("Package does not exist.");
}
private Collection<Class> getClasses(Collection<Element> elements) {
Collection<Class> result = new ArrayList<Class>();
for (Element element : elements) {
if (isBlock(element)) result.add((Class) element);
}
return result;
}
}
\ No newline at end of file
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