|
|
Re: EReference and primitive types [message #429967 is a reply to message #429943] |
Thu, 07 May 2009 16:39 |
Adrian Herscu Messages: 33 Registered: July 2009 |
Member |
|
|
Hi Dirk, and thanks for your fast reply :)
Dirk Hoffmann wrote:
> 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.
Unfortunately, this requires the user to define the primitive types in
his model instance.
>
> 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.
The solution I have found is to make Field abstract and extend it with a
Reference (that is associated with a Type) and with an Attribute (that
has "type" attribute with a Primitive EType, where "Primitive" is
defined as an EEnum enumerating the available primitives).
>
> 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.
|
|
|
Powered by
FUDForum. Page generated in 0.03748 seconds