java8 stream的使用

从list集合中拿出两个字段组成MAP

Map userMap = userList.stream().collect(Collectors.toMap(User::getTjid, User::getName))

从list集合中拿出一个字段作为key,对象作为value

Map userMap = userList.stream().collect(Collectors.toMap(User::getTjid, Function.identity()));

从list对象集合中提取出一个字段组成list,并且去重

Set opttjidSet = tbTradeRecords.stream().map(TbTradeRecord::getOperatortjid).collect(Collectors.toSet());

把list通过某个属性分组

Map> loanRecordGroup = loanRecords.stream().collect(Collectors.groupingBy(LoanRecordInfoResp::getTjid));

 

你可能感兴趣的:(技术,jooq)