在过滤器内部调用方法时出现Java流错误



我有两个类如下

package academy.learnprogramming;

public class Employee {
int empId;
int salary;
String name;
String designation;

Employee(int empId, String name, String designation, int salary){
this.empId = empId;
this.name = name;
this.designation = designation;
this.salary = salary;
}

public String toString(){
return "ID = "+empId + ", Name = "+name+", Designation = "+designation+", Salary = "+salary;
}
public String filterData(){
if(empId == 111 && salary > 1000){
return "ID = "+empId + ", Name = "+name+", Designation = "+designation+", Salary = "+salary;
}
return  "";
}
}
package academy.learnprogramming;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class Main {
public static List<Employee> employeeList = new ArrayList<Employee>();
public static void main(String[] args) {
Employee employee1 = new Employee(111,"Niranjan","SSE",10000);
Employee employee2 = new Employee(112,"Niramal","SSE-1",10001);
Employee employee3 = new Employee(113,"Nijaguna","SSE-2",10);

employeeList.add(employee1);
employeeList.add(employee2);
employeeList.add(employee3);
/*for (Employee employee: employeeList){
System.out.println(employee.toString());
}*/
employeeList.stream().forEach(System.out::println);
System.out.println("****");
//employeeList.stream().filter(employee -> employee.salary > 10000 ).forEach(System.out::println);
employeeList.stream().filter(Employee::filterData).map(employee->employee).collect(Collectors.toList());
System.out.println("*******Sorted list*******");
}
}

我在下面一行得到错误,说方法引用中的返回类型不好:无法将java.lang.String转换为布尔值

employeeList.stream().filter(Employee::filterData).map(employee->employee).collect(Collectors.toList());

有人能帮帮我吗?学习java概念

如果有人能帮上忙,那就太好了

Stream#filter期望流类型为布尔值的函数,并将删除该函数返回false的所有元素。employe# filterData方法返回一个String,因此它不能作为一个用于筛选的函数。相反,您需要一个返回布尔值的方法:如果流应该保留该员工,则为true,如果不应该保留该员工,则为false。