Skip to main content



      Home
Home » Modeling » EMF » Default value of attribute with type enum
Default value of attribute with type enum [message #534411] Wed, 19 May 2010 01:24 Go to next message
Eclipse UserFriend
I have EMF model with a class that has attribute of type EEnum.
Default value is not specified (should be null). When I invoke get
(without setting it before ) I receive enumeration literal that is the
first in the EEnum. Multiplicity of the attribute is [0..1] so I think,
that get value should return null.

Maybe somebody can comment why it is implemented in this way?

Regards,

Rimvydas
Re: Default value of attribute with type enum [message #534457 is a reply to message #534411] Wed, 19 May 2010 05:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
IMHO returning null is the worse option. Even Boris admited that the
null returns in SWT were the "biggest mistake" ;-), see also
http://www.eclipsecon.org/2010/sessions/sessions?id=1427
I would rather model the "null" value explicit, e.g. as "not set". If
you really need "null" you can probably even model null explicitly in
the Enum (not tested).
To avoid surprises, it would be good to enforce a default value at any
enumeration...
Cheers
Jonas


Rimvydas Vaidelis wrote:
> I have EMF model with a class that has attribute of type EEnum.
> Default value is not specified (should be null). When I invoke get
> (without setting it before ) I receive enumeration literal that is the
> first in the EEnum. Multiplicity of the attribute is [0..1] so I think,
> that get value should return null.
>
> Maybe somebody can comment why it is implemented in this way?
>
> Regards,
>
> Rimvydas
Re: Default value of attribute with type enum [message #534458 is a reply to message #534457] Wed, 19 May 2010 05:21 Go to previous messageGo to next message
Eclipse UserFriend
Addition: The default value is automatically set on the first literal
you set. So my last suggestion is already implemented by EMF...


Jonas wrote:
> Hi,
> IMHO returning null is the worse option. Even Boris admited that the
> null returns in SWT were the "biggest mistake" ;-), see also
> http://www.eclipsecon.org/2010/sessions/sessions?id=1427
> I would rather model the "null" value explicit, e.g. as "not set". If
> you really need "null" you can probably even model null explicitly in
> the Enum (not tested).
> To avoid surprises, it would be good to enforce a default value at any
> enumeration...
> Cheers
> Jonas
>
>
> Rimvydas Vaidelis wrote:
>> I have EMF model with a class that has attribute of type EEnum.
>> Default value is not specified (should be null). When I invoke get
>> (without setting it before ) I receive enumeration literal that is the
>> first in the EEnum. Multiplicity of the attribute is [0..1] so I think,
>> that get value should return null.
>>
>> Maybe somebody can comment why it is implemented in this way?
>>
>> Regards,
>>
>> Rimvydas
Re: Default value of attribute with type enum [message #534459 is a reply to message #534458] Wed, 19 May 2010 05:26 Go to previous messageGo to next message
Eclipse UserFriend
FYI, there has been some (detailed) discussion on this topic earlier:
http://www.eclipse.org/forums/index.php?t=tree&th=161533 &#page_top

gr. Martin

Jonas wrote:
> Addition: The default value is automatically set on the first literal
> you set. So my last suggestion is already implemented by EMF...
>
>
> Jonas wrote:
>> Hi,
>> IMHO returning null is the worse option. Even Boris admited that the
>> null returns in SWT were the "biggest mistake" ;-), see also
>> http://www.eclipsecon.org/2010/sessions/sessions?id=1427
>> I would rather model the "null" value explicit, e.g. as "not set". If
>> you really need "null" you can probably even model null explicitly in
>> the Enum (not tested).
>> To avoid surprises, it would be good to enforce a default value at any
>> enumeration...
>> Cheers
>> Jonas
>>
>>
>> Rimvydas Vaidelis wrote:
>>> I have EMF model with a class that has attribute of type EEnum.
>>> Default value is not specified (should be null). When I invoke get
>>> (without setting it before ) I receive enumeration literal that is
>>> the first in the EEnum. Multiplicity of the attribute is [0..1] so I
>>> think,
>>> that get value should return null.
>>>
>>> Maybe somebody can comment why it is implemented in this way?
>>>
>>> Regards,
>>>
>>> Rimvydas


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Default value of attribute with type enum [message #534473 is a reply to message #534459] Wed, 19 May 2010 05:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi Martin,

I noticed CDO in the thread you mentioned. Could that be related to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=306998 ?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 19.05.2010 11:26, schrieb Martin Taal:
> FYI, there has been some (detailed) discussion on this topic earlier:
> http://www.eclipse.org/forums/index.php?t=tree&th=161533 &#page_top
>
> gr. Martin
>
> Jonas wrote:
>> Addition: The default value is automatically set on the first literal
>> you set. So my last suggestion is already implemented by EMF...
>>
>>
>> Jonas wrote:
>>> Hi,
>>> IMHO returning null is the worse option. Even Boris admited that the
>>> null returns in SWT were the "biggest mistake" ;-), see also
>>> http://www.eclipsecon.org/2010/sessions/sessions?id=1427
>>> I would rather model the "null" value explicit, e.g. as "not set".
>>> If you really need "null" you can probably even model null
>>> explicitly in the Enum (not tested).
>>> To avoid surprises, it would be good to enforce a default value at
>>> any enumeration...
>>> Cheers
>>> Jonas
>>>
>>>
>>> Rimvydas Vaidelis wrote:
>>>> I have EMF model with a class that has attribute of type EEnum.
>>>> Default value is not specified (should be null). When I invoke get
>>>> (without setting it before ) I receive enumeration literal that is
>>>> the first in the EEnum. Multiplicity of the attribute is [0..1] so
>>>> I think,
>>>> that get value should return null.
>>>>
>>>> Maybe somebody can comment why it is implemented in this way?
>>>>
>>>> Regards,
>>>>
>>>> Rimvydas
>
>
Re: Default value of attribute with type enum [message #534475 is a reply to message #534473] Wed, 19 May 2010 06:07 Go to previous messageGo to next message
Eclipse UserFriend
It seems related but the topic of the bugzilla is more related to invalid default values (whereby the thread discusses
the whole default value philosophy of EMF in general).

I seem to remember that sometimes EMF generates an EnumObject datatype (for nullable types) for an enum type but I am
not sure when this happens or that I remember this correctly...

gr. Martin

Eike Stepper wrote:
> Hi Martin,
>
> I noticed CDO in the thread you mentioned. Could that be related to
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=306998 ?
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Am 19.05.2010 11:26, schrieb Martin Taal:
>> FYI, there has been some (detailed) discussion on this topic earlier:
>> http://www.eclipse.org/forums/index.php?t=tree&th=161533 &#page_top
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Addition: The default value is automatically set on the first literal
>>> you set. So my last suggestion is already implemented by EMF...
>>>
>>>
>>> Jonas wrote:
>>>> Hi,
>>>> IMHO returning null is the worse option. Even Boris admited that the
>>>> null returns in SWT were the "biggest mistake" ;-), see also
>>>> http://www.eclipsecon.org/2010/sessions/sessions?id=1427
>>>> I would rather model the "null" value explicit, e.g. as "not set".
>>>> If you really need "null" you can probably even model null
>>>> explicitly in the Enum (not tested).
>>>> To avoid surprises, it would be good to enforce a default value at
>>>> any enumeration...
>>>> Cheers
>>>> Jonas
>>>>
>>>>
>>>> Rimvydas Vaidelis wrote:
>>>>> I have EMF model with a class that has attribute of type EEnum.
>>>>> Default value is not specified (should be null). When I invoke get
>>>>> (without setting it before ) I receive enumeration literal that is
>>>>> the first in the EEnum. Multiplicity of the attribute is [0..1] so
>>>>> I think,
>>>>> that get value should return null.
>>>>>
>>>>> Maybe somebody can comment why it is implemented in this way?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Rimvydas
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Default value of attribute with type enum [message #534484 is a reply to message #534475] Wed, 19 May 2010 06:21 Go to previous message
Eclipse UserFriend
Guys,

EMF treats EEnums just like primitives, i.e., like int where the first
enum is like 0. It's certainly possible to create an EDataType whose
instance type name is the generated enum; features of that type can be
null. We automatically produce such an EDataType when generating a
model from XML Schema to support nillable elements.


Martin Taal wrote:
> It seems related but the topic of the bugzilla is more related to
> invalid default values (whereby the thread discusses the whole default
> value philosophy of EMF in general).
>
> I seem to remember that sometimes EMF generates an EnumObject datatype
> (for nullable types) for an enum type but I am not sure when this
> happens or that I remember this correctly...
>
> gr. Martin
>
> Eike Stepper wrote:
>> Hi Martin,
>>
>> I noticed CDO in the thread you mentioned. Could that be related to
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=306998 ?
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>>
>> Am 19.05.2010 11:26, schrieb Martin Taal:
>>> FYI, there has been some (detailed) discussion on this topic earlier:
>>> http://www.eclipse.org/forums/index.php?t=tree&th=161533 &#page_top
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Addition: The default value is automatically set on the first
>>>> literal you set. So my last suggestion is already implemented by
>>>> EMF...
>>>>
>>>>
>>>> Jonas wrote:
>>>>> Hi,
>>>>> IMHO returning null is the worse option. Even Boris admited that
>>>>> the null returns in SWT were the "biggest mistake" ;-), see also
>>>>> http://www.eclipsecon.org/2010/sessions/sessions?id=1427
>>>>> I would rather model the "null" value explicit, e.g. as "not set".
>>>>> If you really need "null" you can probably even model null
>>>>> explicitly in the Enum (not tested).
>>>>> To avoid surprises, it would be good to enforce a default value at
>>>>> any enumeration...
>>>>> Cheers
>>>>> Jonas
>>>>>
>>>>>
>>>>> Rimvydas Vaidelis wrote:
>>>>>> I have EMF model with a class that has attribute of type EEnum.
>>>>>> Default value is not specified (should be null). When I invoke
>>>>>> get (without setting it before ) I receive enumeration literal
>>>>>> that is the first in the EEnum. Multiplicity of the attribute is
>>>>>> [0..1] so I think,
>>>>>> that get value should return null.
>>>>>>
>>>>>> Maybe somebody can comment why it is implemented in this way?
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Rimvydas
>>>
>>>
>
>
Previous Topic:[DataBinding] ComputedList refresh
Next Topic:Problem Creating Resource
Goto Forum:
  


Current Time: Sun Aug 31 18:39:24 EDT 2025

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

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

Back to the top