Home » Modeling » EMF » Default value of EAttribute typed to an Enumeration
| | | | |
Re: Default value of EAttribute typed to an Enumeration [message #431767 is a reply to message #431761] |
Fri, 24 July 2009 11:30 |
|
--=-/Riwv3yOaf5JPGdE7NHz
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, John,
Myself, I always include an explicit "none" value in my enumerations, as
the first literal, when the enumeration needs to have optional
semantics. Sometimes I even go so far is implementing the "Null Object"
pattern by mixing in a common interface that defines an isUndefined()
operation, which usually is implemented in an enum as "this == NONE".
Would that help your situation? It would mean only updating your enums,
not your attributes of those types.
Cheers,
Christian
On Thu, 2009-07-23 at 23:57 +0000, John T.E. Timm wrote:
> Of course after spending all this time investigating the code templates
> and obsessing over getting an Enumeration based attribute to be null, I
> realized that I all really need is for the attribute to be marked as
> "unsettable" to add unset to the value space. How embarrasing. :) Anyways,
> I see now that regardless of what I set the value to, if I call setXXX, it
> will mark it as set and will be serialized as such. Unfortunately, I have
> literally hundreds of attributes in my model that need to be changed.
>
> Thakns,
>
> JT
>
--=-/Riwv3yOaf5JPGdE7NHz
Content-Type: text/html; charset="utf-8"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, John,<BR>
<BR>
Myself, I always include an explicit "none" value in my enumerations, as the first literal, when the enumeration needs to have optional semantics. Sometimes I even go so far is implementing the "Null Object" pattern by mixing in a common interface that defines an isUndefined() operation, which usually is implemented in an enum as "this == NONE".<BR>
<BR>
Would that help your situation? It would mean only updating your enums, not your attributes of those types.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Thu, 2009-07-23 at 23:57 +0000, John T.E. Timm wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Of course after spending all this time investigating the code templates
and obsessing over getting an Enumeration based attribute to be null, I
realized that I all really need is for the attribute to be marked as
"unsettable" to add unset to the value space. How embarrasing. :) Anyways,
I see now that regardless of what I set the value to, if I call setXXX, it
will mark it as set and will be serialized as such. Unfortunately, I have
literally hundreds of attributes in my model that need to be changed.
Thakns,
JT
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-/Riwv3yOaf5JPGdE7NHz--
|
|
| |
Re: Default value of EAttribute typed to an Enumeration [message #431776 is a reply to message #431774] |
Fri, 24 July 2009 16:03 |
John T.E. Timm Messages: 161 Registered: July 2009 |
Senior Member |
|
|
Ed:
What it came down to was that I actually didn't need null. What I really
needed was the "unset" value. The isUnsettable property takes care of this
for me.
Thanks,
JT
Ed Merks wrote:
> John,
> I'm not sure in the end if you got what you wanted. You could make it
> unsettable and you could specify an explicit default. If you really
> want null to be a value, you have to create another EDataType that wraps
> the generated enumeration type; any model with EEnums generated from XML
> Schemas does this automatically to support nillable elements...
> John T.E. Timm wrote:
>> Of course after spending all this time investigating the code
>> templates and obsessing over getting an Enumeration based attribute to
>> be null, I realized that I all really need is for the attribute to be
>> marked as "unsettable" to add unset to the value space. How
>> embarrasing. :) Anyways, I see now that regardless of what I set the
>> value to, if I call setXXX, it will mark it as set and will be
>> serialized as such. Unfortunately, I have literally hundreds of
>> attributes in my model that need to be changed.
>>
>> Thakns,
>>
>> JT
>>
|
|
|
Re: Default value of EAttribute typed to an Enumeration [message #431777 is a reply to message #431767] |
Fri, 24 July 2009 16:09 |
John T.E. Timm Messages: 161 Registered: July 2009 |
Senior Member |
|
|
Hi Christian,
Thank you for your suggestions. I am modeling various controlled
vocabularies that are part of a standard with these enumerations. I think
that adding an explicit "none" value could work well in my situation but I
would like to leave the actual enumerations alone if possible. In my
application, I decided that I care more about the "unset" value. At first
I thought that getting the Enumeration to be null was the only way, but
with the isUnsettable option, the generated code keeps track of a separate
"unset" value which I feel should work well.
Thanks,
JT
Christian W. Damus wrote:
> Hi, John,
> Myself, I always include an explicit "none" value in my enumerations, as
> the first literal, when the enumeration needs to have optional
> semantics. Sometimes I even go so far is implementing the "Null Object"
> pattern by mixing in a common interface that defines an isUndefined()
> operation, which usually is implemented in an enum as "this == NONE".
> Would that help your situation? It would mean only updating your enums,
> not your attributes of those types.
> Cheers,
> Christian
> On Thu, 2009-07-23 at 23:57 +0000, John T.E. Timm wrote:
>> Of course after spending all this time investigating the code templates
>> and obsessing over getting an Enumeration based attribute to be null, I
>> realized that I all really need is for the attribute to be marked as
>> "unsettable" to add unset to the value space. How embarrasing. :) Anyways,
>> I see now that regardless of what I set the value to, if I call setXXX, it
>> will mark it as set and will be serialized as such. Unfortunately, I have
>> literally hundreds of attributes in my model that need to be changed.
>>
>> Thakns,
>>
>> JT
>>
|
|
|
Goto Forum:
Current Time: Wed Sep 25 16:00:36 GMT 2024
Powered by FUDForum. Page generated in 0.04052 seconds
|