我有一个Map<Integer,Doctor> docLib=new HashMap<>();
用来保存Doctor
类。
Doctor
类有getSpecialization()
方法可以返回一个String
类型的值,
getPatients()
方法可以返回一个类为Person
的集合。
在主方法中,我输入:
public Map<String,Set<Person>> getPatientsPerSpecialization(){
Map<String,Set<Person>> res=this.docLib.entrySet().stream().
map(d->d.getValue()).
collect(groupingBy(d->d.getSpecialization(),
d.getPatients()) //error
);
return res;
}
如您所见,我在使用groupingBy
方法时遇到了问题。我尝试将相同的值d发送给该方法,但结果是错误的。如何解决这个问题?