I made a for loop in the main template that should print HELLO: WORLD for each class in my model using function getClasses.
The problem is that it is written only once.
GetClasses:
public Set<Class> getClasses(Model model) {
Set<Class> classi = new HashSet<>();
List<Type> types = model.getOwnedTypes();
for (Type type : types) {
if (type instanceof Class) {
classi.add((Class) type);
}
}
for(Class classe : classi)
{
System.out.println(classe);
}
return classi;
}
MAIN:
[for(aClass : Class | getClasses(aModel))]
[consoleMessage('HELLO', 'WORLD')/]
[/for]
RESULT:
org.eclipse.uml2.uml.internal.impl.ClassImpl@33aeca0b (name: Prodotto, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
org.eclipse.uml2.uml.internal.impl.ClassImpl@5b1f29fa (name: Ordine, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
org.eclipse.uml2.uml.internal.impl.ClassImpl@4b7e96a (name: CategoriaProdotto, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
org.eclipse.uml2.uml.internal.impl.ClassImpl@6b44435b (name: ProdottoPerOrdine, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
HELLO: WORLD
From the result is clear that the Set is properly filled but the for is not properly iterating.