Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Texo] generating a default value for an attribute
[Texo] generating a default value for an attribute [message #1431552] Thu, 25 September 2014 21:10 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 199
Registered: July 2009
Senior Member
Hi all,
I've set a default value for an attribute in my ecore model file. But if
I generate the Java code there's no assignment of this value. How do I
create it in the right way?

TIA,
Ralf.
Re: [Texo] generating a default value for an attribute [message #1436700 is a reply to message #1431552] Fri, 03 October 2014 09:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ralf,
Missed your post... I tested it for int/string/enum and for all 3 the default value worked. What type is your eattribute?

Here are my examples:

private String title = "TEST";

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
private int pages = 100;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
private BookCategory category = BookCategory.SCIENCEFICTION;



gr. Martin

On 25-09-14 23:10, Ralf Heydenreich wrote:
> Hi all,
> I've set a default value for an attribute in my ecore model file. But if
> I generate the Java code there's no assignment of this value. How do I
> create it in the right way?
>
> TIA,
> Ralf.
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] generating a default value for an attribute [message #1437655 is a reply to message #1436700] Sat, 04 October 2014 20:17 Go to previous message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 199
Registered: July 2009
Senior Member
Am 03.10.2014 um 11:23 schrieb Martin Taal:
> Hi Ralf,
> Missed your post... I tested it for int/string/enum and for all 3 the
> default value worked. What type is your eattribute?
>
> Here are my examples:
>
> private String title = "TEST";
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> *
> * @generated
> */
> private int pages = 100;
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> *
> * @generated
> */
> private BookCategory category = BookCategory.SCIENCEFICTION;
>
>
>
> gr. Martin
>
> On 25-09-14 23:10, Ralf Heydenreich wrote:
>> Hi all,
>> I've set a default value for an attribute in my ecore model file. But if
>> I generate the Java code there's no assignment of this value. How do I
>> create it in the right way?
>>
>> TIA,
>> Ralf.
>>
>
>


Hi Martin,
thanks for your answer. Now, I've tested it with EBooleanObject value
and it works as expected. But I have to use the simple type version
("true/false") instead of "Boolean.TRUE" or "Boolean.FALSE".

It does not work if I use EIntegerObject. Whether if I use
"java.lang.Integer.valueOf(1)" nor if I use the simple "1" as Default
Value Literal.

Are the default values only useable with simple types?

Greetz,
Ralf.
Previous Topic:[CDO] Using conflict resolver
Next Topic:EFS provider based on EMF model of resources
Goto Forum:
  


Current Time: Wed Aug 21 18:42:32 GMT 2019

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

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

Back to the top