Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gendoc » Checking for empty list of stereotypes
Checking for empty list of stereotypes [message #1710214] Mon, 05 October 2015 11:51 Go to next message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member
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 12:00 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
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 12:26 Go to previous message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member
Thanks, this works fine.
Previous Topic:Displaying all attributes of a class
Next Topic:Displaying association ends
Goto Forum:
  


Current Time: Thu Apr 25 02:16:59 GMT 2024

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

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

Back to the top