You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Here is an example of how to collect all children from the com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element and avoid recursion using a simple for cycle:

    List<Element> children = new ArrayList<Element>(); 
    Element current = ... 
    children.add(current);
    // if the current element has children, list will be increased. 
    for (int i = 0; i < children.size(); i++)
    {
        current = children.get(i);
        // add all children into end of this list, so it emulates a recursion. 
        children.addAll(current.getOwnedElement());
    }

It is highly recommended to use more advanced collecting methods from com.nomagic.magicdraw.uml.Finder utility:

 

 

Related pages