Default values (EDEFAULT) for EAttributes that use EDataTypes with EType paramters (generics) is not generated #22
claesrosell
started this conversation in
General
Replies: 2 comments 2 replies
-
Perhaps it's a corner case not explored in the previous 18 years. The method could test if getDefaultValueLiteral is not null as an additional || condition. E.g., maybe something like this has minimal chance of regression while covering your case: |
Beta Was this translation helpful? Give feedback.
1 reply
-
I have tested to generate our meta-models with your suggested change and for them, it seems to work without any unwanted side effects. Should I create an issue and provide a PR? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
I do not know if this is a bug or not. Hence, I started a discussion first.
"default value literal"'s on EAttribute:s which uses an EDateType with EType parameters (generics) does not seem to be fully supported.
To explain the problem I am using this simple meta model
A simple EClass called
MyClass
with one single EAttributemyAttribute
which uses the EDataTypeEMyDataType
which in turn has a type parameter. The EAttribute is given the default value literal "1"The generated code for MyClassImpl will miss a MY_ATTRIBUTE_EDEFAULT declaration and eIsSet() and eUnset() methods of MyClassImpl switch/case statement for the EAttribute will be generated to handle "null" as the default value.
So if something like this is done:
myValue
will have the valuenull
However, the
initializePackageContents
method of the generated MyModelPackageImpl class will be generated to support default value of the EAttribute.So if I call:
... the default value will be an instance of MyDataType ( created from the string "1" via
MyModelFactoryImpl.createEMyDataTypeFromString()
)I have looked into the jet templates and the genmodel and the
.hasEDefault()
method of GenFeatureImpl.java explicitly checks if there are type parameters defined and if so, it returns false:So my question really is: Is this expected behavior or is it a bug?
Beta Was this translation helpful? Give feedback.
All reactions