How to specifiy enumeration literal as default value in UML Attribute?

只愿长相守 提交于 2020-01-14 03:28:07

问题


I currently doing some model transformations using EMF-UML-Implementation. In my model transformation I create an uml class with some attributes. The attributes are type of enumerations I also created. Some of the attribute should get a default value. The default value should be enumeration literals.

The question now is, how do I get the enumeration literals to the defaultValue-property of the Property.

I already have found that I have to use ValueSpecification. But the UML superstructure says not much about that (page 139 f.). Which properties do I have to use for setting the defaultValue to enumeration literals?

I think the main problem I have is, that the use of ValueSpecification is unclear to me. Currently I only use default to set the default values, which is type of String.


回答1:


The defaultValue-property takes a ValueSpecification argument. So in your case, you need an InstanceValue for this purpose (which derives from ValueSpecification). The InstanceValue itself has an instance-property, which takes an InstanceSpecification as argument. As EnumerationLiteral derives from InstanceSpecification, you can now simply assign one of your EnumerationLiterals to it.



来源:https://stackoverflow.com/questions/11989969/how-to-specifiy-enumeration-literal-as-default-value-in-uml-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!