I have to classes, Container and Containable, and I'd like to implement qualified names ( root/containerA/containerB/containableXYZ )
So, Container derives from Containable and Containable has a fullName Property which I set as derived, transient & volatile which works
return (parent != null) ? parent.getName() + SEPARATOR + getName() : getName();
But now I'm worried that in big models at each level of the hierarchy the same path is computed unnecessarily - Each container could cache it's path
But if the parent of the container changes - how do i automatically recompute it's path?
In EMF objects are contained in a Resource which has a tree hierarchy. What you can do is to extend the Resource to intercept when an object is being attached or detached from the tree.
See: ResourceImpl.attached()
Other thing you can do is to override the method eBasicSetContainer() in your class. The best is to have an abstract common root class for your all model classes. Then what you can do is to intercept this method and update the path when the new container objects is not null.
In both cases (intercepting Resource or EObject), make sure that you also re-compute the path of any contained element in the subtree of the element being changed. This can be easily done by re-computing the path recursively iterating over the subtree using: EcoreUtil.getAllProperContents(EObject)
BTW, you can also use the EcoreUtil.getIdentification() which returns the qualified name of the element using its URI.