The blog entry does not make sense. Look at the API for Predicates
:
Predicates.in(users)
creates a Predicate
of the generic type User
, i.e. Predicate<User>
. This predicate takes an argument of type User
in its Predicate#apply(T)
method. The class ShouldNotHaveDigitsInLoginPredicate
implements Predicate<User>
itself and is therefore not of type User
. Therefore, your IDE warns you of a type mismatch.
What you can do is:
User user = getSomeUser();
Predicates.and(Predicates.in(users), new ShouldNotHaveDigitsInLoginPredicate())
.apply(user);