Extending external (non-ecore) class [message #426490] |
Thu, 08 January 2009 05:54  |
Eclipse User |
|
|
|
Hello,
is it possible to extend a java class with an ecore class?
By entering an instance type name it is possible to implement/extend
java interfaces, but for java classes the code generated from the
genmodel is broken.
A simple example would be java.util.ArrayList as base class that is
extended by EcoreArrayList.
Cheers,
Alexander
|
|
|
Re: Extending external (non-ecore) class [message #426492 is a reply to message #426490] |
Thu, 08 January 2009 06:37  |
Eclipse User |
|
|
|
Alexander,
Comments below.
Alexander Dotor wrote:
> Hello,
>
> is it possible to extend a java class with an ecore class?
Yes and no...
>
> By entering an instance type name it is possible to implement/extend
> java interfaces, but for java classes the code generated from the
> genmodel is broken.
Yes, because EClasses generally mapped to interfaces and interfaces can
be multiply inherited. A class isn't an interface and you can't extend
more than one. Also, instances of EClasses are assumed to be EObjects
(as well as InternalEObjects) which is always achieved by subclasses
BasicEObjectImpl in some way. In theory one could mix in (duplicate)
the entire implementation hierarchy of BasicEObjectImpl, but that's a
lot of work and a lot of copying.
>
> A simple example would be java.util.ArrayList as base class that is
> extended by EcoreArrayList.
The two would even have conflicting rules for the implementation of
equality. It's better to look at composing such things than extending
them. Existing classes should generally be handled as EDataTypes...
>
> Cheers,
> Alexander
|
|
|
Powered by
FUDForum. Page generated in 0.03725 seconds