Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Change default values (specification) for enum literals automatically(How to change default value (LiteralString) for enumeration litorals with UML 2 API)
Change default values (specification) for enum literals automatically [message #1818623] Fri, 20 December 2019 17:29 Go to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
I try to change the default value (LiteralString) for enumeration literals with the UML2. API and I can not find a method for enum literals to change the default value.
I expect a method like setDefaultValue(String newValue). On other hand is there method to get/set the ValueSpecification for an enum literal.



Re: Change default values (specification) for enum literals automatically [message #1818707 is a reply to message #1818623] Tue, 24 December 2019 06:50 Go to previous messageGo to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hello,

Try something like :
Property property = getMyPropoerty();
Type type = getMyType();
EnumerationLiteral enumLiteral = getEnumerationLiteral();

InstanceValue instanceValue = (InstanceValue) property.createDefaultValue("default", type, UMLPackage.eINSTANCE.getInstanceValue());
instanceValue.setInstance(enumLiteral);


You can also use :
property.setDefaultValue(instanceValue);


HTH.

Yoann.


Re: Change default values (specification) for enum literals automatically [message #1819081 is a reply to message #1818707] Tue, 07 January 2020 12:48 Go to previous message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Yoann,
due the usage of the cast (InstanceValue) in your code snippet, I come up with the idea of doing this

LiteralString litStringSpec = (LiteralString) enumLit.getSpecification();
litStringSpec.setValue("newDefaultValue");

to change the default value of an enumeration literal. This works fine for me.
Thanks
BR Michael
Previous Topic:Sequence diagrams: guided selection of operations?
Next Topic:Import of UML model exported by Enterprise Architect
Goto Forum:
  


Current Time: Fri Apr 26 07:47:23 GMT 2024

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

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

Back to the top