allMatch:Stream中全部元素符合传入的predicate返回 true
anyMatch:Stream中只要有一个元素符合传入的predicate返回 true
noneMatch:Stream中没有一个元素符合传入的predicate返回 true
List<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("five");
Boolean bl = list.stream().anyMatch(x->x.length()==4);
System.out.println(bl);
打印true
boolean anyMatch = catList.stream().parallel().noneMatch(e -> e.getId().equals(newArticleBO.getCategoryId()));
if (anyMatch) {
return R.en(ResultEnum.ARTICLE_CATEGORY_NOT_EXIST_ERROR);
}
正文完