Java Iterable<;搜索标准>;不适用于参数

Java Iterable<;搜索标准>;不适用于参数,java,spring-boot,Java,Spring Boot,我想为Product类创建一个规范类。它将有一个谓词类来处理SearchCriteria 当我尝试输入搜索标准时出错: The method forEach(Consumer<? super SearchCriteria>) in the type Iterable<SearchCriteria> is not applicable for the arguments ((<no type> key, <no type> criteria) -&g

我想为Product类创建一个规范类。它将有一个谓词类来处理SearchCriteria

当我尝试输入搜索标准时出错:

The method forEach(Consumer<? super SearchCriteria>) in the type Iterable<SearchCriteria> is not applicable for the arguments ((<no type> key, <no type> criteria) -> {})

我遗漏了什么?

您正试图将
列表
迭代为
映射
。你必须改变

searchCriterias.forEach((key, criteria) -> {


您正试图将
列表
迭代为
映射
。你必须改变

searchCriterias.forEach((key, criteria) -> {


您的答案是正确的,但我的代码中还有更多问题。以这种方式实现规范是个坏主意。所以我决定应用单个规范,并在服务级别时将它们与合并。您的答案是正确的,但我的代码中还有更多的问题。以这种方式实现规范是个坏主意。所以我决定应用单个规范,并在服务级别中将它们与合并。
searchCriterias.forEach((key, criteria) -> {
searchCriterias.forEach((criteria) -> {