Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to get the child classes only?
How to get the child classes only? [message #1826080] Sat, 18 April 2020 15:52 Go to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 15
Registered: April 2020
Junior Member
Hello Everyone!

i just want to get the child classes of specific class e.g; NODE (the name of the parent class) .
i have tried many operations but they are not working for me :(, like

[for (c: EClass | anEPackage.eAllContents())]
[if (c.name.toString() = 'NODE')]
[if (c.eContainer().oclAsType(NODE))][/comment]
[for (cc: EClass | c.eContents(EClass))][cc.name/]
[for (a:EAttribute | cc.eAllContents())][a.name/] [/for]
[for (r:EReference | cc.eAllContents())][r.name/] [/for]
[/for]
[/if]

[/for]

Regards,
fatima
Re: How to get the child classes only? [message #1826082 is a reply to message #1826080] Sat, 18 April 2020 17:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6839
Registered: July 2009
Senior Member
Hi

Easy. It's Set{} since EMF does not support nested classes.

Regards

Ed Willink
Re: How to get the child classes only? [message #1826116 is a reply to message #1826082] Sun, 19 April 2020 19:24 Go to previous messageGo to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 15
Registered: April 2020
Junior Member
Hi Willink!
Thanks for reply ! problem solved. :)

Another question , how to get specific attribute of a class in a for loop?

Regards,
fatima
Re: How to get the child classes only? [message #1826129 is a reply to message #1826116] Mon, 20 April 2020 05:02 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6839
Registered: July 2009
Senior Member
Hi

New question should be new topic.

An attribute of a class is invariant so you get get it just the same as you would outside the loop. Something like: MyClass.ownedAttributes->select(name = wantedName).

Refards

Ed Willink
Previous Topic:Compile Accelo with Maven&Tycho&Travis
Next Topic:How to read the graphical notations?
Goto Forum:
  


Current Time: Sun Sep 20 18:54:43 GMT 2020

Powered by FUDForum. Page generated in 0.01973 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top