List subs = getDirectSubordinates(workNo);
// 一行代码, 把List 转成 Map
val subMap = subs.stream...().collect(Collectors.toMap(EmployeeJobDTO::getWorkNo, it -> it));
代码解析
public static Collector..., Map> toMap(
Function keyMapper, // Key 映射器
Function<? super T, ?...toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new);
}
public static Map..., Map> toMap(Function<? super T, ?