Java stream,用法集合单独取出对象中一个属性成为集合或数组
集合
List<DictEntity> dictEntityList = dictService.findByType(6);
取出属性为集合
List<String> stateNameList = dictEntityList.stream().map(DictEntity::getName).collect(Collectors.toList());
取出属性为数组
Long[] ids = dictEntityList.stream().map(DictEntity::getId).toArray(Long[]::new);
集合去重
dictEntityList.stream().distinct().collect(Collectors.toList());