1.toMap的几个方法
public static Collector> toMap(Function super T, ? extends K> keyMapper,Function super T, ? extends U> valueMapper) {
return toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new);
}
public static Collector> toMap(Function super T, ? extends K> keyMapper,Function super T, ? extends U> valueMapper,BinaryOperator mergeFunction) {
return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new);
}
public static > Collector toMap(Function super T, ? extends K> keyMapper,Function super T, ? extends U> valueMapper,BinaryOperator mergeFunction,Supplier mapSupplier) {
BiConsumer accumulator
= (map, element) -> map.merge(keyMapper.apply(element),
valueMapper.apply(element), mergeFunction);
return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID);
}