Home » Modeling » EMF » Finding a specialization of a modeled class?
Finding a specialization of a modeled class? [message #419950] |
Fri, 13 June 2008 16:38  |
Eclipse User |
|
|
|
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 17:16   |
Eclipse User |
|
|
|
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
>
|
|
|
Re: Finding a specialization of a modeled class? [message #419955 is a reply to message #419952] |
Fri, 13 June 2008 23:17   |
Eclipse User |
|
|
|
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 08:11  |
Eclipse User |
|
|
|
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
>>>
>
>
>
|
|
|
Goto Forum:
Current Time: Thu Jul 17 00:58:50 EDT 2025
Powered by FUDForum. Page generated in 0.10660 seconds
|