List<CoverLog> list = collect2.stream().filter(distinctByKey(CoverLog::getStockCode)).collect(Collectors.toList());
Map<String, CoverLog> collect4 = collect2.stream().collect(Collectors.toMap(CoverLog::getStockCode, Function.identity(), (l, r) -> l.getUpdateTime().before(r.getUpdateTime()) ? r : l));
Collection<CoverLog> values = collect4.values();
Map<String, CoverLog> map = new HashMap<>();
collect2.forEach(e -> {
CoverLog coverLog = map.get(e.getStockCode());
if (coverLog == null || coverLog.getUpdateTime().before(e.getUpdateTime())) {
map.put(e.getStockCode(), e);
}
});
Map<String, List<CoverLog>> collect5 = col
Map<String, CoverLog> collect4 = collect2.stream().collect(Collectors.toMap(CoverLog::getStockCode, Function.identity(), (l, r) -> l.getUpdateTime().before(r.getUpdateTime()) ? r : l)); Collection<CoverLog> values = collect4.values(); Map<String, CoverLog> map = new HashMap<>(); collect2.forEach(e -> { CoverLog coverLog = map.get(e.getStockCode()); if (coverLog == null || coverLog.getUpdateTime().before(e.getUpdateTime())) { map.put(e.getStockCode(), e); } }); //根据股票code去重获取一个map ,key为code values为list集合 Map<String, List<CoverLog>> collect5 = collect2.stream().collect(Collectors.groupingBy(CoverLog::getStockCode));
ct2.stream().collect(Collectors.groupingBy(CoverLog::getStockCode));标签:map,code,Map,股票,coverLog,CoverLog,最新,getUpdateTime,getStockCode From: https://www.cnblogs.com/ZhangZiXue/p/16830004.html