In the upcoming latest version(12.0) of Guava, there will be a class named FluentIterable.
This class provides the missing fluent API for this kind of stuff.
Using FluentIterable, you should be able doing something like this:
final Collection<String> filtered = FluentIterable
.from(tokens)
.transform(new Function<String, String>() {
@Override
public String apply(final String input) {
return input == null ? "" : input.trim();
}
})
.filter(new Predicate<String>() {
@Override
public boolean apply(final String input) {
return !Strings.isNullOrEmpty(input);
}
})
.toImmutableList();