|
Re: Xtend2: extended type-based collection filters [message #1009831 is a reply to message #1009819] |
Fri, 15 February 2013 20:07 |
|
Hi,
(1)
have a look what actually happens: The filter call is mapped to org.eclipse.xtext.xbase.lib.IterableExtensions.filter(Iterable<?>, Class<T>)
which calls (with some indirections org.eclipse.xtext.xbase.lib.IterableExtensions.filter(Iterable<?>, Class<T>))
this contains something filter(unfiltered, Predicates.instanceOf(type));
=> the call
a.filter(typeof(String)) is the same as a.filter(Predicates::instanceOf(typeof(String)))
=> you could easily build an extension like
def <T> Iterable<T> filter(Iterable<T> unfiltered, Class<T>... types) {
unfiltered.filter(Predicates::or(types.map[Predicates::instanceOf(it)]))
}
(2) here you could do write something that uses Predicates::not
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03740 seconds