Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Property#setDefaultValue of EnumerationLiteral
Property#setDefaultValue of EnumerationLiteral [message #1563544] Wed, 14 January 2015 08:59 Go to next message
Andreas Jakobik is currently offline Andreas JakobikFriend
Messages: 12
Registered: November 2011
Junior Member
Hi,
I'm trying to set a Property defaultValue to an EnumerationLiteral. However, after the following code has been executed, the enum literal specification value is null, and the default value shows a 0.

Here is xtend code snippet:

val EnumerationLiteral A_LITERAL = // lookup of enumeration literal
val Property p = // lookup of class property (which has a Enumeration as type)

// The following line calls void org.eclipse.uml2.uml.Property.setDefaultValue(ValueSpecification value)
p.defaultValue = A_LITERAL.specification  


What is wrong? How do I correctly assign an enumeration literal as a default value?

I'm using an old version of UML2 api (Version: 3.1.2.v201010261927) on IBM RSA 8.0.4.

Thanks a lot!

/Andreas
Re: Property#setDefaultValue of EnumerationLiteral [message #1563991 is a reply to message #1563544] Wed, 14 January 2015 14:35 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1167
Registered: July 2009
Location: Canada
Senior Member

Hi, Andreas,

Try this:

-------- 8< --------

p.createDefaultValue(null, A_LITERAL.enumeration,
UMLPackage.Literals.INSTANCE_VALUE) as InstanceValue => [
instance = A_LITERAL
]

-------- >8 --------

A value of enumeration type is represented by an InstanceValue, because
EnumerationLiterals are InstanceSpecifications of their Enumeration
types.

HTH,

Christian

On 2015-01-14 08:59:23 +0000, Andreas Jakobik said:

> Hi,
> I'm trying to set a Property defaultValue to an EnumerationLiteral.
> However, after the following code has been executed, the enum literal
> specification value is null, and the default value shows a 0.
> Here is xtend code snippet:
>
> val EnumerationLiteral A_LITERAL = // lookup of enumeration literal
> val Property p = // lookup of class property (which has a Enumeration as type)
>
> // The following line calls void
> org.eclipse.uml2.uml.Property.setDefaultValue(ValueSpecification value)
> p.defaultValue = A_LITERAL.specification
> What is wrong? How do I correctly assign an enumeration literal as a
> default value?
>
> I'm using an old version of UML2 api (Version: 3.1.2.v201010261927) on
> IBM RSA 8.0.4.
>
> Thanks a lot!
>
> /Andreas
Re: Property#setDefaultValue of EnumerationLiteral [message #1564127 is a reply to message #1563991] Wed, 14 January 2015 16:17 Go to previous message
Andreas Jakobik is currently offline Andreas JakobikFriend
Messages: 12
Registered: November 2011
Junior Member
Great, that works fine. Here is an excerpt from running code:
                              (te as Property).createDefaultValue(null, null, 
				UMLPackage$Literals::INSTANCE_VALUE) as InstanceValue => [
 					instance = NOSTATUS_LITERAL
 				]

(I set type parameter to null, in order to get exact same emx encoding as if done by MetaModelAgent GUI.)
Thank you very much for the quick reply!
MVH,
Andreas
Previous Topic:Rich Text Editor for SysML Comments
Next Topic:Stereotype owning two specialization
Goto Forum:
  


Current Time: Sun Apr 22 20:02:07 GMT 2018

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

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