Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2012-04-03 15:25:11 +0000
committercdumoulin2012-04-03 15:25:11 +0000
commit4bd24089abfc070fcb001e4ad3afa71182ac67e0 (patch)
tree1dbc1ad68b0132454bafa99018774e018956d148 /extraplugins
parent6ac29fe6789d1bddfeefe29e07fa31ae88c585b1 (diff)
downloadorg.eclipse.papyrus-4bd24089abfc070fcb001e4ad3afa71182ac67e0.tar.gz
org.eclipse.papyrus-4bd24089abfc070fcb001e4ad3afa71182ac67e0.tar.xz
org.eclipse.papyrus-4bd24089abfc070fcb001e4ad3afa71182ac67e0.zip
ASSIGNED - bug 375759: [Java Code Generator] Improve generator
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375759 - Generate literal values prefixed with the Enum type name.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.generator.transfo.umltojdt/transforms/uml/uml2jdt2.qvto31
1 files changed, 28 insertions, 3 deletions
diff --git a/extraplugins/java/org.eclipse.papyrus.java.generator.transfo.umltojdt/transforms/uml/uml2jdt2.qvto b/extraplugins/java/org.eclipse.papyrus.java.generator.transfo.umltojdt/transforms/uml/uml2jdt2.qvto
index a80be48bfb4..a53851d9112 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.generator.transfo.umltojdt/transforms/uml/uml2jdt2.qvto
+++ b/extraplugins/java/org.eclipse.papyrus.java.generator.transfo.umltojdt/transforms/uml/uml2jdt2.qvto
@@ -873,9 +873,34 @@ mapping uml::Property::propertyToField() : JDTField
// type
type := self.type.map transformTypeToType();
- if(not self.defaultValue.isNull() ) then
- value := self.defaultValue.stringValue()
- endif;
+ // Specify the default value
+ if(not self.defaultValue.isNull() ) then {
+ value := self.defaultValue.valueSpecificationToString();
+ } endif;
+}
+
+/**
+ * Compute the default value from the ValueSpecification.
+ * Check if this is a special case.
+ *
+ */
+query uml::ValueSpecification::valueSpecificationToString() : String {
+
+ switch {
+ case (self.oclIsTypeOf(uml::InstanceValue)) {
+ var iv := self.oclAsType(uml::InstanceValue );
+
+ // Is it an EnumLiteral ?
+ if( iv.instance.oclIsTypeOf(uml::EnumerationLiteral)) then {
+ // This is an enum literal. Prefix it with its typeName
+ return iv.type.name + "." + iv.instance.name;
+ } endif;
+ }
+ else {
+ return self.stringValue()
+ }
+ };
+ return "";
}
/**

Back to the top