如果你想要优化这段代码,可以考虑使用方法引用来代替Lambda表达式,并且使用ArrayList来代替默认的Collectors.toList()方法返回的List实现。下面是优化后的代码:\n\njava\nList<String> collect = manageToolConfigList.stream()\n .filter(f -> StringUtils.equals(f.getType(), String.valueOf(ActivityToolTypeEnum.SCORE_STATISTICS.getValue())))\n .sorted()\n .map(item -> getScoreCensusToolResult(item.getCode(), enablePriority))\n .collect(Collectors.toCollection(ArrayList::new));\n\n\n这样,优化后的代码将返回一个List<String>对象。


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

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