Hi all,
during migration from Xtend/Xpand to Xtend2 I have the following problem with the new collect syntax.
Let's say we have a World which contains multiple Country elements. Every country contains multiple Company elements.
If I do
def getSortedCompanies(World it) {
getAllCompanies.sortBy(e|e.sortOrder)
}
def getAllCompanies(World it) {
countries.map(e|e.companies)
}
the field sortOrder is not visible in the first rule.
If I do
def getAllCompanies(World it) {
countries.map(e|e.companies) as Iterable<Company>
}
I get an error message in the generated Java file as conversion from List<EList<Company>> to Iterable<Company> is not possible.
This is why I did
def getAllCompanies(World it) {
countries.map(e|e.companies) as List<Company>
}
But when trying to run the Xtend generator it crashes with:
Caused by: java.lang.ClassCastException: org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList cannot be cast to ....Company
I think the problem is that I have a List of EList elements while I should have only a List.
What am I overlooking?
TIA
Axel
[Updated on: Wed, 02 May 2012 07:46]
Report message to a moderator