我正在研究一个类似的谓词链接问题,并提出了以下方法
public static <T> Predicate<T> chain (Function<T,Predicate<T>> mapFn, T[]args) {
    return Arrays.asList(args)
        .stream()
        .map(x->mapFn.apply(x))
        .reduce(p->false, Predicate::or);
}
第一个要链接的参数是一个lambda(函数),它返回一个lambda(谓词),所以它需要几个箭头
public static void yourExample() {
    String[] filterVals = { "1", "2" };
    Arrays.asList("1","2","3")
        .stream()
        .filter(chain(x-> (y-> y.equals(x)), filterVals))
        .count();
}
为了进行比较,这是我试图实现的目标...
public static void myExample() {
    String[] suffixes = { ".png", ".bmp" };
    Predicate<String> p = chain (x-> y-> y.endsWith(x), suffixes);
    File[] graphics = new File("D:/TEMP").listFiles((dir,name)->p.test(name));
    Arrays.asList(graphics).forEach(System.out::println);
}