当我在 Sonar 中检查时,结果是:
Replace this lambda with a method reference.
它实际上指的是这个:
.filter(s -> aIDetailsDto.getResult().getIdNo().equals(s))
我的代码如下:
AIDetailsDto aIDetailsDto = aaaService
.getDetailsByUserId(userId)
if (!ObjectUtils.isEmpty(aIDetailsDto)) {
List<String> kvpValues = callService.getKVPCodes(NewConstants.REMOVED)
.stream()
.filter(s -> aIDetailsDto.getResult().getIdNo().equals(s))
我尝试更改它,但出现错误。 有谁知道如何更改它吗?
最佳答案
您应该使用.filter(aIDetailsDto.getResult().getIdNo()::equals)
。
关于java - Sonar : Replace this lambda with a method reference.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51398282/