|Re: Using oclIsTypeOf() with a variable argument [message #870905 is a reply to message #870888]
||Thu, 10 May 2012 08:43
| Ed Willink
Registered: July 2009
The status of type-valued expressions is pretty unclear in the OCL
specification; it could be argued that even oclIsTypeOf(Integer) is
The thinking for OCL 2.5, that is prototyped in the pivot-binding of
Eclipse OCL is that type-valued and potentially element-valued
expressions should be no different from datatype and object-valued
So today if you're using the Xtext OCL Console, or the Java API for the
pivot model, some usages may be possible, although I'm fairly sure that
I've fixed some relevant issues for Juno, so the Indigo release may be
flaky in this area.
Your specific text makes no sense, since you're mixing string-valued and
type-valued arguments without providing an overload.
You should be able to do, in OCL.
let searchType : Type = MyClass in someSet->select(oclIsKindOf(searchType))
[oclIsKindOf is nearly always better than oclIsTypeOf]
let searchType : String = 'MyClass' in someSet->select(oclType().name =
oclType() is also not implemented in the Ecore binding of Eclipse OCL,
but you can do
select(oclAsType(ecore::EObject).eClass().name = searchType)
On 10/05/2012 08:41, Marius Gröger wrote:
> I want specify the type argument in oclIsTypeOf(OclType) as a variable,
> for example like so:
> var searchType : String := "MyClass";
> someSet->select(o | o->oclIsTypeOf(searchType);
> Is something this this possible?
Powered by FUDForum
. Page generated in 0.02185 seconds