使用Stream流优化上述代码可以如下所示:\n\nfinal TalentAbility talent = createTalent(user);\nIntStream.range(row.getFirstCellNum(), row.getLastCellNum())\n .mapToObj(i -> {\n final String cellValue = getCellValue(row, i);\n final BiConsumer<TalentAbility, String> setter = CONVERT_MAP.get(i);\n return setter != null ? setter.accept(talent, cellValue) : null;\n })\n .collect(Collectors.toList());

使用Stream流优化代码 - 简化循环操作

原文地址: https://www.cveoy.top/t/topic/pZpl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录