Reputation: 3728
I get this error when trying to compile:
The method filter(Iterable<T>, Predicate<? super T>)
in the type Iterables is not applicable for the arguments (Iterator<PeopleSoftBalance>, ColumnLikePredicate<PeopleSoftBalance>
)
Here is the ColumnLikePredicate class sig:
public class ColumnLikePredicate<T extends RowModel> implements Predicate<T>
What am I doing wrong?
Upvotes: 3
Views: 864
Reputation: 2026
Note that Guava includes both Iterators.filter() and Iterables.filter() methods. Call the first method to filter an Iterator and the second method to filter an Iterable.
Upvotes: 3
Reputation: 139921
Sounds like you are passing an Iterator
to a method that expects an Iterable
.
An iterator over a collection
Implementing this interface allows an object to be the target of the "foreach" statement.
Iterator
is an object that can be used to iterate over a (different) collection. Iterable
is an object that can be iterated over.
I would guess that you have some sort of collection
and you are calling something like Iterables.filter(collection.iterator(), predicate)
. The Iterables
class wants you to pass the Iterable itself, like:
Iterables.filter(collection, predicate)
Upvotes: 14