我正在尝试使用方法引用来压缩我的代码。这是我正在尝试改进的一条线:
assertThat("only true & false strings allowed",
records.stream().map(Record::getType)
.allMatch(s -> "true".equals(s) || "false".equals(s)));
使用方法参考可能会更好:
assertThat("only true & false strings allowed",
records.stream().map(Record::getType).allMatch("true"::equals));
但是我可以在谓词中添加“false”吗?