Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Generic Enumeration Literal
Generic Enumeration Literal [message #1783968] Tue, 20 March 2018 19:44 Go to next message
John Dziurlaj is currently offline John DziurlajFriend
Messages: 1
Registered: March 2018
Junior Member
I have a number of UML classes that share a similar structure. An enumeration "X" has a number of values, including X::other. When a class instance has X::other for this attribute, then another attribute, OtherType must be defined. The OCL constraint looks something like this:

self.Type = X::other implies not self.OtherType.oclIsUndefined()


This works well enough. However, each class has its own enumeration (of a different type) so the explicit referencing of a classifier will not work if I try to apply this rule to multiple elements. I tried something like:

self.Type = self.Type.oclType()::other implies not self.OtherType.oclIsUndefined()


but received an error regarding the use of ::

Is there a way to accomplish this?
Re: Generic Enumeration Literal [message #1784116 is a reply to message #1783968] Thu, 22 March 2018 16:03 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Generic functionality generally requires reflection, which OMG OCL explicitly excludes although there are aspects of the specification that require it.

The Pivot-based Eclipse OCL used within Payprus supports reflection. oclType() returns an OCL::Class which is pretty similar to a UML::Class except that property names are rationalized, so something like (untested) oclType().oclAsType(pivot::Enumeration).ownedLiterals->select(name='other') might help you. (The cast to Enumeration should probably be unnecessary._

Regards

Ed Willink
Previous Topic:def / derive in interactive OCL console
Next Topic:Validate OCL from ecore standalone => Exception java.lang.NullPointerException: null
Goto Forum:
  


Current Time: Sun May 05 18:59:31 GMT 2024

Powered by FUDForum. Page generated in 0.04086 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top