I have a Map<X, Y> and List<X>, I would like to extract the values from Map<X, Y> by providing the List<X>, which will result in List<Y>. One way to do this is
List<X> keys = getKeys();
Map<X, Y> map = getMap();
List<Y> values = Lists.newArrayListWithCapacity(keys.size());
for(X x : keys){
values.add(map.get(x));
}
Now again I need to remove nulls in values (List<Y>) by using Predicate or something. Any better way to do this?
Is there any good reason why this method isn’t there in google collections library?
Something like this: