Skip to main content



      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 10:42 Go to next message
Eclipse UserFriend
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 #904507 is a reply to message #904500] Tue, 28 August 2012 10:54 Go to previous messageGo to next message
Eclipse UserFriend
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 11:25 Go to previous messageGo to next message
Eclipse UserFriend
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 #904545 is a reply to message #904517] Tue, 28 August 2012 12:46 Go to previous messageGo to next message
Eclipse UserFriend
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 13:20 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Ed I did not know that syntax

Regards

Andrea
Re: [Acceleo] select over a Set(String) object [message #904802 is a reply to message #904558] Wed, 29 August 2012 03:24 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 08:21:03 EDT 2025

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

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

Back to the top