Java Code Examples for org.eclipse.uml2.uml.Element#getOwner()

The following examples show how to use org.eclipse.uml2.uml.Element#getOwner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityNodeResolver.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
private <ItemType extends Element> Class getParentClass(ItemType element) {
	Element parent = element.getOwner();
	while (!parent.eClass().equals(UMLPackage.Literals.CLASS)) {
		parent = parent.getOwner();
	}
	return (Class) parent;
}
 
Example 2
Source File: MDDUtil.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static <T extends Element> Optional<T> findNearest(Element reference, EClass eClass) {
    if (eClass.isInstance(reference))
        return Optional.of((T) reference);
    Element owner = reference.getOwner();
    if (owner == null)
        return Optional.empty();
    return findNearest(owner, eClass);
}