firstPublish.getFunds().stream().filter(firstFund ->
adviceCodeSet.contains(firstFund.getCode())).peek(firstFund -> firstFund.setAdviceState(true));
如上代码,使用 stream 的 peek 进行 set 操作,idea 提示:
提示说Stream.peek()
的返回值被忽略。
peek返回具有相同元素的流,以供进一步处理,你不需要这样做,你应该改用forEach。
修改后:
firstPublish.getFunds().forEach(firstFund ->
firstFund.setAdviceState(adviceCodeSet.contains(firstFund.getCode())));