|How to define Xtend method like: collection.retainAll(e|expression with e) ? [message #491384]
||Wed, 14 October 2009 08:17
Registered: October 2009
I want to define in Xtend a method that modify the content of a list according to a boolean expression applied to each element in the list.|
Basically, I want to be able to define in Xtend a method that:
* takes a boolean expression as argument (like Collection.select)
* actually modify the provided collection (and returns Void)
I want to call this Xtend method from an Xpand template of this kind:
create Set[MyType] result getXYZ(MyOtherType this) :
result.retainAll(e|e.associationFromMyType == this);
And I don't know how to define such a parameter in Xtend:
Void retainAll(Collection this, ??? conditionArgument) :
let temp = this.select(conditionArgument) :
?set this to temp?;
Is this any possible?
|Re: How to define Xtend method like: collection.retainAll(e|expression with e) ? [message #491509 is a reply to message #491391]
||Wed, 14 October 2009 16:25
| Sven Efftinge
Registered: July 2009
It's not possible to introduce new higher order functions, since|
you'ld have to extend the parser.
result.removeAll(result.select(e|e.associationFromMyType != this));
> Hi Sebastian, thanks for fast answer.
> Would it be possible then to subclass the java code that implements it?
> What is the Java class that implements the high order collection functions?
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Need professional support on Xtext or Xtend?
Mail to: xtext (at) itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Powered by FUDForum
. Page generated in 0.03903 seconds