Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Initialize multivalued attributes/references
Initialize multivalued attributes/references [message #423117] Tue, 23 September 2008 14:25 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hi,

when adding a multivalued attribute to an EClass, the generated code doesn't
initialize the attribute. Thus,
calling getMyAttributeList() might return null. The solution is to perform a
check or modify the generated code.

I'd prefer that the corresponding field is initlialized with an Empty List.
Is there an option in the genmodel? in the model itself?

Before I've always hacked the generated class, but I don't feel comfortable.
Maybe I should just modify the Factory methods?

Thanks. I promise to add replies to the FAQ.

Felix
Re: Initialize multivalued attributes/references [message #423119 is a reply to message #423117] Tue, 23 September 2008 14:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Felix,

Comments below.

Felix Dorner wrote:
> Hi,
>
> when adding a multivalued attribute to an EClass, the generated code doesn't
> initialize the attribute. Thus,
> calling getMyAttributeList() might return null. The solution is to perform a
> check or modify the generated code.
>
This doesn't sound quite right to me. All features for which upperBound
> 1 will have an initialized list.
> I'd prefer that the corresponding field is initlialized with an Empty List.
> Is there an option in the genmodel? in the model itself?
>
Is this list just a single valued feature who's value happens to be a
list (like from an XSD list type)?
> Before I've always hacked the generated class, but I don't feel comfortable.
> Maybe I should just modify the Factory methods?
>
If it's just a single valued feature that happens to has a list value,
presumably you empty list is represented as the empty string so you
could make that the default value of the attribute...
> Thanks. I promise to add replies to the FAQ.
>
> Felix
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Initialize multivalued attributes/references [message #423142 is a reply to message #423119] Tue, 23 September 2008 18:16 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hi Ed,
>> when adding a multivalued attribute to an EClass, the generated code
>> doesn't initialize the attribute. Thus,
>> calling getMyAttributeList() might return null. The solution is to
>> perform a check or modify the generated code.
>>
> This doesn't sound quite right to me. All features for which upperBound
> > 1 will have an initialized list.

Uhm, the only thing i can think of that the behaviour is different for
EAttributes and EReferences. I'm talking about an EReference.

> Is this list just a single valued feature who's value happens to be a
> list (like from an XSD list type)?

I directly create the model with the tree editor, just like the
author->*book example. So the type is book and its upperbound is -1.


Felix
Re: Initialize multivalued attributes/references [message #423150 is a reply to message #423142] Tue, 23 September 2008 19:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Felix,

Comments below.

Felix Dorner wrote:
> Hi Ed,
> >> when adding a multivalued attribute to an EClass, the generated code
>>> doesn't initialize the attribute. Thus,
>>> calling getMyAttributeList() might return null. The solution is to
>>> perform a check or modify the generated code.
>>>
>> This doesn't sound quite right to me. All features for which
>> upperBound > 1 will have an initialized list.
>
> Uhm, the only thing i can think of that the behaviour is different for
> EAttributes and EReferences. I'm talking about an EReference.
No, it's the same. That makes it even more mysterious.
>
>> Is this list just a single valued feature who's value happens to be a
>> list (like from an XSD list type)?
>
> I directly create the model with the tree editor, just like the
> author->*book example. So the type is book and its upperbound is -1.
There must be something that's gone unsaid so far because multi-valued
features (attributes or references) will always return a list, never
null. Can you think of anything odd about your model that makes it
different from author -> books which we know works properly?
>
>
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Initialize multivalued attributes/references [message #423198 is a reply to message #423150] Wed, 24 September 2008 17:46 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed,

It was my fault. Seems I was really tired and looked in the wrong place.
..

Sorry,
Felix
Previous Topic:How do I inherit from an EDataType
Next Topic:[Teneo] mapModel problem?
Goto Forum:
  


Current Time: Fri Apr 19 15:13:48 GMT 2024

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

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

Back to the top