There's already a predicate in Predicates that will help you here -- Predicates.notNull() -- and you can use Iterables.filter() and the fact that Lists.newArrayList() can take an Iterable to clean this up a little more.
Read full article from java - Is there an elegant way to remove nulls while transforming a Collection using Guava? - Stack Overflow
No comments:
Post a Comment