【小工具】stream的各种使用方式 将某个字段取出ListStringidslist.stream().map(Bean::getId).collect(Collectors.toList());ListBean转MapString,Bean示例GenTabletablegenTableMapper.selectGenTableByName(tableName);ListGenTableColumntableColumnstable.getColumns();MapString,GenTableColumntableColumnMaptableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName,Function.identity()));filter过滤器使用示例// 筛选出dataList中没有的数据ListStringfilterListaddList.stream().filter(i-!dataList.contains(i)).collect(Collectors.toList());判断是否包含// CollectionString authorities;booleanflagauthorities.stream().anyMatch(x-contains.contains(x));重新过滤ListBeanListBeantolistlist.stream().filter(s-other.getId().equals(s.getId())).map(item-{BeanasbeannewBean();// asbean.setXx(item.getItemText());returnasbean;}).collect(Collectors.toList());根据条件升序// 根据条件升序ListBeancollectlist.stream().sorted(Comparator.comparing(Bean::getOrderSort)).collect(Collectors.toList());// 根据条件降序ListBeancollectlist.stream().sorted(Comparator.comparing(Bean::getLvl).reversed()).collect(Collectors.toList());以逗号分隔ListBean中的某个字段ids.stream().map(Bean::getXx).collect(Collectors.joining(,))groupby特定字段ListBeanlistthis.list(queryWrapper);MapString,ListBeanallListlist.stream().collect(Collectors.groupingBy(Bean::getType));