Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Extending external (non-ecore) class
Extending external (non-ecore) class [message #426490] Thu, 08 January 2009 10:54 Go to next message
adotor is currently offline adotorFriend
Messages: 46
Registered: July 2009
Member
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 11:37 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Resource loading
Next Topic:Literals missing from code generated by and ANT script
Goto Forum:
  


Current Time: Sat Apr 27 02:52:27 GMT 2024

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

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

Back to the top