Combine filter and card in Xtend collections

Given some repetitive variable v and type T , I often find myself writing code like

v.filter[it instanceof T].map[it as T]

Is there any helper that performs the same functionality in one step?

+4
source share
1 answer

You can use v.filter(T) (or the legacy v.filter(typeof(T)) syntax), which is the v.filter(T.class) syntax for the Java equivalent v.filter(T.class) .

+7
source

All Articles