Hi.
I want to realize a light-weight design-by-contract pattern using active annotations.
It should look like this:
@Contract(requires='elements.filter[!empty].size != 0')
def doSomething(List<String> elements) {
...
}
The content of the requires rule is a string, but in fact is valid xtend code.
As far as I understood with the active annotation concept one can hook into the xtend-to-java generator process.
So I want to generate a piece of code like assertTrue(elements.filter[!empty].size != 0) after entering the method.
How this is done in principle is clear to me.
But I need to transform the xtend expression (elements.filter[!empty].size != 0) into a java expression first, since at the end everything needs to be java code.
How can I achieve this?
Thanks,
Torsten