Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] select over a Set(String) object
[Acceleo] select over a Set(String) object [message #904500] Tue, 28 August 2012 14:42 Go to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

How may I execute a select over an set of String?
I mean setOfString->select(='test') is wrong, also setOfString->select(self='test')
what is the right syntax?


Follow me on Twitter @andreasindico

Re: [Acceleo] select over a Set(String) object [message #904507 is a reply to message #904500] Tue, 28 August 2012 14:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Have you tried defining an iterator variable and using it?

Regards

Ed Willink

On 28/08/2012 15:42, Andrea Sindico wrote:
> How may I execute a select over an set of String?
> I mean setOfString->select(='test') is wrong, also
> setOfString->select(self='test')
> what is the right syntax?
Re: [Acceleo] select over a Set(String) object [message #904517 is a reply to message #904500] Tue, 28 August 2012 15:25 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

My aim is not to iterate over the set. I need to do something only if a string (say 'test') is contained in the set. If the set does not contain that string I need to do something else.
i.e.

[if setOfString->select(??='test')->notEmpty()]
generate something
[else]
generate something else
[/if]


How would you do that by means of an iterator?


Follow me on Twitter @andreasindico

Re: [Acceleo] select over a Set(String) object [message #904545 is a reply to message #904517] Tue, 28 August 2012 16:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
setOfString->exists(s : String | s = 'test')
setOfString->includes('test')

Regards

Ed Willink

On 28/08/2012 16:25, Andrea Sindico wrote:
> My aim is not to iterate over the set. I need to do something only if
> a string (say 'test') is contained in the set. If the set does not
> contain that string I need to do something else.
> i.e.
>
>
> [if setOfString->select(??='test')->notEmpty()]
> generate something
> [else]
> generate something else
> [/if]
>
>
> How would you do that by means of an iterator?
>
Re: [Acceleo] select over a Set(String) object [message #904558 is a reply to message #904500] Tue, 28 August 2012 17:20 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

Thank you Ed I did not know that syntax

Regards

Andrea


Follow me on Twitter @andreasindico

Re: [Acceleo] select over a Set(String) object [message #904802 is a reply to message #904558] Wed, 29 August 2012 07:24 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Andrea,

Ed's answer is right, I'll just add that you can also use iterators in select and reject operations with the same syntax he has outlined for "exists" :

[setOfString->select(s : String | s = 'test')]


i.e :
variable.operation(iterator | body)
. This same syntax exists for all 'iteration' operation : select, reject, collect, exists, forAll, isUnique, one, any and sortedBy.

Though of course, "includes" is better if you only need to check whether you set contains a given value.

Laurent Goubet
Obeo
Previous Topic:[Acceleo] select distinct
Next Topic:Acceleo induced InvalidRegistryObjectException
Goto Forum:
  


Current Time: Fri Apr 26 18:02:17 GMT 2024

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

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

Back to the top