Using oclIsTypeOf() with a variable argument [message #870888] |
Thu, 10 May 2012 07:41 |
Eclipse User |
|
|
|
Hi,
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?
Regards
Marius
|
|
|
Re: Using oclIsTypeOf() with a variable argument [message #870905 is a reply to message #870888] |
Thu, 10 May 2012 08:43 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
The status of type-valued expressions is pretty unclear in the OCL
specification; it could be argued that even oclIsTypeOf(Integer) is
unparseable.
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
expressions.
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]
Or
let searchType : String = 'MyClass' in someSet->select(oclType().name =
searchType)
oclType() is also not implemented in the Ecore binding of Eclipse OCL,
but you can do
select(oclAsType(ecore::EObject).eClass().name = searchType)
Regards
Ed Willink
On 10/05/2012 08:41, Marius Gröger wrote:
> Hi,
>
> 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?
>
> Regards
> Marius
|
|
|
Re: Using oclIsTypeOf() with a variable argument [message #870917 is a reply to message #870905] |
Thu, 10 May 2012 09:07 |
Eclipse User |
|
|
|
On 10.05.2012 10:43, Ed Willink wrote:
> let searchType : String = 'MyClass' in someSet->select(oclType().name =
> searchType)
>
> oclType() is also not implemented in the Ecore binding of Eclipse OCL,
> but you can do
>
> select(oclAsType(ecore::EObject).eClass().name = searchType)
Thanks!
Marius
|
|
|
Powered by
FUDForum. Page generated in 0.02013 seconds