Xtend loop break

In Xtend, is it possible to break the loop or check to end the loop?

«FOR e:d.entitys» «FOR a:e.attributes» «IF a.eClass.name.contentEquals('Something')» «e.name» "This output should be output one for each Entity e" «ENDIF» «ENDFOR» «ENDFOR» 

My conclusion:

 Entity 1 "This output should be output one for each Entity e" Entity 1 "This output should be output one for each Entity e" Entity 1 "This output should be output one for each Entity e" Entity 2 "This output should be output one for each Entity e" Entity 4 "This output should be output one for each Entity e" Entity 4 "This output should be output one for each Entity e" 

But I want:

 Entity 1 "This output should be output one for each Entity e" Entity 2 "This output should be output one for each Entity e" Entity 4 "This output should be output one for each Entity e" 

How can my desired result be realized? I heard that you can call another method or something similar, but I don’t know how to do this, can someone show me some code for this problem? Thanks:)

+4
source share
1 answer

You can use the kit to store records that you have already visited. As an example, consider the following program:

 def static void main(String... args) { val list = #['my', 'possibly', 'possibly', 'duplicated', 'duplicated', 'duplicated', 'entities'] val visited = new LinkedHashSet println( '''«FOR a:list» «IF visited.add(a)» «a» "This output should be output one for each Entity e" «ENDIF» «ENDFOR»''') } 

It outputs:

 my "This output should be output one for each Entity e" possibly "This output should be output one for each Entity e" duplicated "This output should be output one for each Entity e" entities "This output should be output one for each Entity e" 
0
source

All Articles