Closed eclipse-ocl-bot closed 1 month ago
By Ed Willink on Nov 21, 2014 13:45
I don't understand why indexOf() and oclAsType() cannot solve the problem.
By Yves BERNARD on Nov 24, 2014 06:23
Maybe my example is not that good. Actually it can easily be solved when you know that the value specification is owned by a slot and that the feature of uml::Slot that owns this value specification is "value".
If you want that this query can work with any value specification (i.e. independently of what it is owned by) you would have to write a specific code for each possible kind of value specification owner.
In the example I gave, the OCL expression: self.owner.oclType().oclType()\ is evaluated to 'Metaclass(UML::Slot)' in the context of one of the value specification. This "metaclass level" could provide the expected genericity but it does not seem possible to cast it to a uml::Class (albeit it should be one, formally).
By Ed Willink on Nov 24, 2014 06:44
(In reply to Yves BERNARD from comment #2)
In the example I gave, the OCL expression: self.owner.oclType().oclType() is evaluated to 'Metaclass(UML::Slot)'
Things have moved on. My OCL colleagues disliked the power/complexity of Metaclass(T) when all that was required was a simple typeof() annotation. The current prototype is much simpler becuase of their comments.
oclType() returns an OCL::Class not a UML::Class.
I raised Bug 452972 neglecting this one, so I'll close this as a duplicate.
This bug has been marked as a duplicate of bug 452972
| --- | --- | | Bugzilla Link | 452683 | | Status | RESOLVED DUPLICATE of bug 452972 | | Importance | P3 normal | | Reported | Nov 21, 2014 11:46 EDT | | Modified | Nov 24, 2014 06:44 EDT | | Version | 5.0.0 | | Reporter | Yves BERNARD |
Description
Continuing discussion I wrongly started in the bug287052 thread:
The point is that the ability to deal with model elements in a generic way is sometimes useful(unavoidable?). Example: assume I have to write a query returning the index of a value specification in a collection assigned to a slot of an instance specification. I need to make it work for any slot of any instance specification. The (classifier,feature) couple allowing to get this information is not known in advance, it has to be discovered. How to do this without generic interfaces as those provided by Ecore?