I can\'t get it to compile, is it even possible to chain predicate lambdas?
Arrays.asList(\"1\",\"2\",\"3\").stream().filter( (e -> e==\"1\" ).or(e-> e
Arrays.asList("1","2","3").stream().filter( Arrays.asList("1", "2")::contains).count();
and yes method "either" is good idea
public static void main(String[] args) {
long count = Arrays.asList("1","2","3").stream().filter(either("1"::equals).or("2"::equals)).count();
System.out.println(count);
}
private static Predicate either(Predicate predicate) {
return predicate;
}
or you can use import static java.util.function.Predicate.isEqual;
and write isEqual("1").or(isEqual("2"))