Are null-able Enums still supported? [message #805602] |
Thu, 23 February 2012 19:00  |
Eclipse User |
|
|
|
Use of "wrapper" data types for EEnum (using org.eclipse.emf.common.util.Enumerator) for null-ability is a common pattern in Ecore, and used to be supported well in MDT/OCL. Is it still intended to be supported in the new implementation and editors?
Currently (tried both SR1 and M5) wrapping e.g. the RoyalAndLoyal's Gender enum into GenderObject (attached) causes the CompleteOCL editor to flag the relevant constraint
inv invariant_Customer7 :
(self.gender = Gender::male) implies self.title = 'Mr.'
with an error Unresolved operation '=' for 'RoyalAndLoyal.ecore::RandL::GenderObject' and 'RoyalAndLoyal.ecore::RandL::Gender'
Also Xtext OCL console in SR1 does not let one evaluate Customer.gender:
Evaluating:
self.gender
Results:
Evaluation failure
Failed to evaluate RoyalAndLoyal.ecore::RandL::Customer.gender
Xtext OCL in M5 evaluates (correctly for my test case) to
Evaluating:
self.gender
Results:
RoyalAndLoyal.ecore::RandL::Gender::male
Old OCL console evaluates and compares fine:
Evaluating:
self.gender = Gender::male
Results:
true
|
|
|
|
Re: Are null-able Enums still supported? [message #806213 is a reply to message #805941] |
Fri, 24 February 2012 12:57   |
Eclipse User |
|
|
|
Thanks, good to hear it is being addressed at the OCL specification level.
From the point of view of "wrapped" enumeration pattern in Ecore, there seem to be two pieces to this. One is being able to instantiate this pattern in model definition parts of OCL, e.g. in OCLinEcore - and I think your answer is related to this.
The second is being able to evaluate OCL expressions using Ecore models [possibly already] exhibiting this pattern. My question was about the latter, since it worked (and works) fine with "mature" OCL, but does not seem to work in the new one - or maybe it is just the new editors?
The pattern itself is probably not uncommon in Ecore. EMF book describes it the context of mapping XSD nillalble elements to Ecore (9.2.2, 9.5.4), so it is most likely to surface in XSD-derived models, but there are other uses as well ...
Just for reference, here is what OCLinEcore looks like for when Gender enum in RoyalAndLoyal is wrapped into GenederObject:
datatype GenderObject : 'org.eclipse.emf.common.util.Enumerator' { serializable }
{
annotation _'http:///org/eclipse/emf/ecore/util/ExtendedMetaData'
(
'name' = 'Gender:Object',
'baseType' = 'Gender'
);
}
[Updated on: Fri, 24 February 2012 12:57] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04538 seconds