Property#setDefaultValue of EnumerationLiteral [message #1563544] |
Wed, 14 January 2015 03:59  |
Eclipse User |
|
|
|
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 09:35   |
Eclipse User |
|
|
|
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 11:17  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.24919 seconds