Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » Current date as default
Current date as default [message #381195] Sun, 26 August 2007 08:31 Go to next message
Eclipse UserFriend
Originally posted by: office.dapissarenko.com

Hello!

In my EMF model I have a class with an EDate attribute. I want this
attribute to have a default value. This default value should be the date,
on which the instance of this class was created (new Date() in plain Java).

How can I do this in the model (*.ecore) ?

Thanks in advance

Dmitri Pissarenko
Re: Current date as default [message #381196 is a reply to message #381195] Sun, 26 August 2007 12:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Dmitri,

Please use the EMF newsgroup, which I've added to the "to" list of the
reply, for questions specifically about EMF. You can't model this
directly just via Ecore because default values are expected to be
constants. You could specialize the field declaration in the Impl class
by marking it with @generated NOT and assigning a new Date() to it
there. Keep in mind that this will create a date instance at the time
the EObject is constructed and that this Date instance will likely be
replaced if this object is created as part of deserialization when that
serialized instance also has a date.


Dmitri Pissarenko wrote:
> Hello!
>
> In my EMF model I have a class with an EDate attribute. I want this
> attribute to have a default value. This default value should be the
> date, on which the instance of this class was created (new Date() in
> plain Java).
>
> How can I do this in the model (*.ecore) ?
>
> Thanks in advance
>
> Dmitri Pissarenko
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Current date as default [message #381197 is a reply to message #381196] Mon, 27 August 2007 13:46 Go to previous message
Eclipse UserFriend
Originally posted by: office.dapissarenko.com

Thanks!
Re: Current date as default [message #599327 is a reply to message #381195] Sun, 26 August 2007 12:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Dmitri,

Please use the EMF newsgroup, which I've added to the "to" list of the
reply, for questions specifically about EMF. You can't model this
directly just via Ecore because default values are expected to be
constants. You could specialize the field declaration in the Impl class
by marking it with @generated NOT and assigning a new Date() to it
there. Keep in mind that this will create a date instance at the time
the EObject is constructed and that this Date instance will likely be
replaced if this object is created as part of deserialization when that
serialized instance also has a date.


Dmitri Pissarenko wrote:
> Hello!
>
> In my EMF model I have a class with an EDate attribute. I want this
> attribute to have a default value. This default value should be the
> date, on which the instance of this class was created (new Date() in
> plain Java).
>
> How can I do this in the model (*.ecore) ?
>
> Thanks in advance
>
> Dmitri Pissarenko
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Current date as default [message #599344 is a reply to message #381196] Mon, 27 August 2007 13:46 Go to previous message
Eclipse UserFriend
Originally posted by: office.dapissarenko.com

Thanks!
Previous Topic:Current date as default
Next Topic:documentation offline
Goto Forum:
  


Current Time: Wed Apr 24 19:20:10 GMT 2024

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

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

Back to the top