[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: EReference and primitive types

Hi Adrian,

what I would do is to describe types with a type hierarchy like so:

AbstractType<>--0..* Field

AbstractType <|--+- PrimitiveType
                 |
                 '- ComplexType

You may extend PrimitiveType further with Integer, String, etc. This has the advantage that you specify the available primitive types in your meta model.

You may alternativly define an enumeration attribute with PrimitiveType. Then you would need to add an EEnum with the respective constants.

You may also add an attribute of type java.lang.class to AbstractType.

It really depends on your application on what approach fits best.

Anyway you need to provide some code that creates the PrimitiveType instances I believe. You may use reflection mechanisms to find them if you used the "extend PrimitiveType" approach.

Regards,
Dirk



Adrian Herscu schrieb:
Hi all,

I am trying to build a meta-model which describes an application that contains types, which contain fields.

Application <>--0..* Type
Type <>--0..* Field

Type has a name attribute. Field has a name attribute too.
Field also has a type reference (EReference). In the instance the reference should be of an existing Type.


So far so good. But how to add primitive types to the system without requiring the user to define them as "Type"-s?

My current solution is to add an enumerated "kind" attribute to the Field. Any better ideas?

Adrian.