Skip to main content



      Home
Home » Eclipse Projects » Gendoc » Checking for empty list of stereotypes
Checking for empty list of stereotypes [message #1710214] Mon, 05 October 2015 07:51 Go to next message
Eclipse UserFriend
Hi,

I have some code to print the list of stereotypes with their attributes:
Applied Stereotypes:
[for (st:Stereotype | dt.getAppliedStereotypes())]<drop/>
•	[st.name/]
[/for]<drop/>

with some additional code to display the stereotype attributes.

However, if the list of stereotypes is empty, I would still see the :Applied stereotypes: " text.

I have tried adding an if oclIsUndefined as explained in the tutorial, page 18:
[if (not (dt.getAppliedStereotypes().oclIsUndefined()))]<drop/>
Applied Stereotypes:

[for (st:Stereotype | dt.getAppliedStereotypes())]<drop/>
•	[st.name/]
[/for]<drop/>
[/if]


but gendoc complains with the error:
Cannot find operation (not()) for the type (Bag(Boolean))

I have tried replacing oclIsUndefined by oclIsEmpty but then the error is
Cannot find operation (oclIsEmpty()) for the type (Stereotype)

What is the way to test if the list of stereotype is empty?

Thanks,

Marc
Re: Checking for empty list of stereotypes [message #1710216 is a reply to message #1710214] Mon, 05 October 2015 08:00 Go to previous messageGo to next message
Eclipse UserFriend
In OCL which is a subset of Acceleo which is a subset of Gendoc.

Operations following a "." are operations on an element
if you want to apply operations on collections you shall use : "->" in your case

[if (not (dt.getAppliedStereotypes()->isEmpty()))]<drop/>


or

[if (dt.getAppliedStereotypes()->notEmpty())]<drop/>
Re: Checking for empty list of stereotypes [message #1710224 is a reply to message #1710216] Mon, 05 October 2015 08:26 Go to previous message
Eclipse UserFriend
Thanks, this works fine.
Previous Topic:Displaying all attributes of a class
Next Topic:Displaying association ends
Goto Forum:
  


Current Time: Mon Jun 23 12:48:24 EDT 2025

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

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

Back to the top