Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Finding a specialization of a modeled class?
Finding a specialization of a modeled class? [message #419950] Fri, 13 June 2008 20:38 Go to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Say I had an ecore model that contained the class Book, and another
ecore model that contained the class Journal that extends Book. Is
there a simple way to locate the names, and possibly hierarchy, of all
the classes that extend Book? In this example, the result would be
Journal. I figure I can, by brute code, search the registry, but I'm
hoping there might be a more elegant solution.

Bryan
Re: Finding a specialization of a modeled class? [message #419952 is a reply to message #419950] Fri, 13 June 2008 21:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Bryan,

Comments below.


Bryan Hunt wrote:
> Say I had an ecore model that contained the class Book, and another
> ecore model that contained the class Journal that extends Book. Is
> there a simple way to locate the names, and possibly hierarchy, of all
> the classes that extend Book? In this example, the result would be
> Journal. I figure I can, by brute code, search the registry, but I'm
> hoping there might be a more elegant solution.
Sometimes folks wonder why something like EClass.eSuperTypes doesn't
have an opposite. It's the same reason why in java.lang.Class you can
access only the super classes/interfaces but not the subclasses. I.e.,
it's open ended. In order to answer the question, what are all the
subclasses of this class (EClass or java.lang.Class), you have to bound
the set of classes, and search in the other direction, i.e., visit all
classes and see which have the given class above them in the hierarchy.

The brute force way, though really quite easy to write, as you've
probably already noticed is quite expensive in that all registered EMF
model plugins will be loaded...
>
> Bryan
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Finding a specialization of a modeled class? [message #419955 is a reply to message #419952] Sat, 14 June 2008 03:17 Go to previous messageGo to next message
Cristi Angheluta is currently offline Cristi AnghelutaFriend
Messages: 25
Registered: July 2009
Junior Member
On Sat, 14 Jun 2008 00:16:08 +0300, Ed Merks <merks@ca.ibm.com> wrote:

> Bryan,
>
> Comments below.
>
>
> Bryan Hunt wrote:
>> Say I had an ecore model that contained the class Book, and another
>> ecore model that contained the class Journal that extends Book. Is
>> there a simple way to locate the names, and possibly hierarchy, of all
>> the classes that extend Book? In this example, the result would be
>> Journal. I figure I can, by brute code, search the registry, but I'm
>> hoping there might be a more elegant solution.
> Sometimes folks wonder why something like EClass.eSuperTypes doesn't
> have an opposite. It's the same reason why in java.lang.Class you can
> access only the super classes/interfaces but not the subclasses. I.e.,
> it's open ended. In order to answer the question, what are all the
> subclasses of this class (EClass or java.lang.Class), you have to bound
> the set of classes, and search in the other direction, i.e., visit all
> classes and see which have the given class above them in the hierarchy.

Can a registered package (or when gets loaded) contribute to this
currently inexistent opposite? I'm thinking at something like
EClass.eRegisteredSubTypes(). I don't really how ... it's just a silly
question.

> The brute force way, though really quite easy to write, as you've
> probably already noticed is quite expensive in that all registered EMF
> model plugins will be loaded...
>>
>> Bryan
>>



--
___________________________________________

Cristi Angheluta
Re: Finding a specialization of a modeled class? [message #419959 is a reply to message #419955] Sat, 14 June 2008 12:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Christi,

It's not a silly question. I have imagined there being a registry where
each class declares its super types in the plugin.xml, but this involves
a massive number of registrations, and worse still, we don't yet support
plugin.xml merging to keep it up to date... We do something similar for
item provider factories where they can declare which base item provider
factories they contribute children to, but this is at a far more coarse
grained level


Cristi Angheluta wrote:
> On Sat, 14 Jun 2008 00:16:08 +0300, Ed Merks <merks@ca.ibm.com> wrote:
>
>> Bryan,
>>
>> Comments below.
>>
>>
>> Bryan Hunt wrote:
>>> Say I had an ecore model that contained the class Book, and another
>>> ecore model that contained the class Journal that extends Book. Is
>>> there a simple way to locate the names, and possibly hierarchy, of
>>> all the classes that extend Book? In this example, the result would
>>> be Journal. I figure I can, by brute code, search the registry, but
>>> I'm hoping there might be a more elegant solution.
>> Sometimes folks wonder why something like EClass.eSuperTypes doesn't
>> have an opposite. It's the same reason why in java.lang.Class you
>> can access only the super classes/interfaces but not the subclasses.
>> I.e., it's open ended. In order to answer the question, what are all
>> the subclasses of this class (EClass or java.lang.Class), you have to
>> bound the set of classes, and search in the other direction, i.e.,
>> visit all classes and see which have the given class above them in
>> the hierarchy.
>
> Can a registered package (or when gets loaded) contribute to this
> currently inexistent opposite? I'm thinking at something like
> EClass.eRegisteredSubTypes(). I don't really how ... it's just a silly
> question.
>
>> The brute force way, though really quite easy to write, as you've
>> probably already noticed is quite expensive in that all registered
>> EMF model plugins will be loaded...
>>>
>>> Bryan
>>>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Validation of Meta- and Instance Models
Next Topic:[CDO/Teneo] HibernateUtil.getCDORevision
Goto Forum:
  


Current Time: Fri Apr 19 21:20:47 GMT 2024

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

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

Back to the top