Home » Modeling » EMF » Default value of attribute with type enum
| | |
Re: Default value of attribute with type enum [message #534459 is a reply to message #534458] |
Wed, 19 May 2010 09:26 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
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 09:53 |
|
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
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: Default value of attribute with type enum [message #534475 is a reply to message #534473] |
Wed, 19 May 2010 10:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
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 10:21 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
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
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Wed Sep 25 19:16:27 GMT 2024
Powered by FUDForum. Page generated in 0.05119 seconds
|