Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Collection whose elements are all different (What is the best way to determine whether the elements in a collection are all different?)
[Acceleo] Collection whose elements are all different [message #895091] Wed, 11 July 2012 12:35 Go to previous message
Tomas Balderas is currently offline Tomas Balderas
Messages: 46
Registered: July 2010
Member
Hello

This question might be trivial for many. I found a solution, but didn't feel comfortable with it.

I want to validate that the names assigned to states in a state machine are different to each other. I wrote this query:

[query public validateStatesNames(aStateMachine: StateMachine): Boolean =
	aStateMachine.getStates()
	->collect(s: State | s.name)
	->asSet()
	->size() = aStateMachine.getNumberStates()
/]


where getStates() returns a collection of instances of State in the receiving instance of StateMachine, and getNumberStates() returns the number of elements on this collection of states.

Do you know about an undocumented operation that performs the evaluation I need? Do you know about a more elegant solution?

Thank you very much.


/TB
 
Read Message
Read Message
Read Message
Previous Topic:xpand and aspects
Next Topic:Retrieve target folder during generation
Goto Forum:
  


Current Time: Thu May 23 10:57:12 EDT 2013

Powered by FUDForum. Page generated in 0.01586 seconds