Stream流List转map用法,真香

UserDto中UserId字段作为key,每个UserDto作为Value

List dtoList= BeanHelper.copyProperties(list, UserDto.class);
Map> map = dtoList.stream().filter(dto -> StringUtil.isNotBlank(dto.getUserId())).collect(Collectors.groupingBy(UserDto::getUserId);

你可能感兴趣的:(随笔,stream,java,lambda)