Is there a "CanAdd" API? [message #1805075] |
Fri, 05 April 2019 08:26  |
Eclipse User |
|
|
|
Hi all!
I am currently searching some EMF-Reflection API like "canAdd", "accepts" or something like that which - for two EObjects A and B - tells me whether I can add B as a child to A.
i.e. something like this
EcoreUtil.canAdd(EObject, EObject) :: bool
... that accesses the structuralFeatures, references incl. types and bounds etc. to answer accordingly.
Is there such an API? (I didn't find something like that, yet. Maybe, I missed something).
Thanks in advance,
Ingo
|
|
|
|
|
|
|
|
Re: Is there a "CanAdd" API? [message #1805140 is a reply to message #1805091] |
Mon, 08 April 2019 05:42  |
Eclipse User |
|
|
|
Ed Merks wrote on Fri, 05 April 2019 14:55Note that this only works for generated models: final Class<?> instanceClass = eReference.getEReferenceType().getInstanceClass();
if (instanceClass.isAssignableFrom(childClass)) Better just to use EClass.isInstance which for a generated model will use Class.isInstance.
Ok, I edited my previous post.
|
|
|
Powered by
FUDForum. Page generated in 0.03279 seconds