Check that Type is of collection type

My usecase is quite simple - if a property of my class is a list, or collection, or map, then I'd like to add method clear<PropertyName>.

I tried using $IF$ with condition
(node, genContext, operationContext)->boolean { 
  node.type.isInstanceOf(ListType); 
}

but it does not work.
Any help?
0
4 comments
Avatar
Permanently deleted user
Given the information you provided it's difficult to tell what is wrong. The 'node' can be an expression or a property declaration, whereas 'type' can be the type operation or the 'type' link.

For the expression 'node', if you're trying to check if the type is conforming to some known type, it's better to use 'isSubtype' or even 'coerce' to required type.

For 'type' link of a property declaration your code is correct, in case the link is an aggregation and you specify property type as an instance of ListType concept.

Please provide more relevant information so we can help you.
0
In my case 'node' is an instance of concept 'Property' and type is children named 'type' of that concept.
0
Which node is stored in this child reference in your case?

You probably know that you can switch on Transient Model saving and check the content of the model on which this generator macro is applied.
0
Avatar
Permanently deleted user
Thanks for code.
0

Please sign in to leave a comment.