Sonal lint :更改此条件,使其不总是评估为真

Sonal lint : change this condition so that it does not always evaluate to true

我正在尝试使用来自 Java 服务的数据 JPA 存储库,如下所示:

@Service
public class APIKeyServiceImpl implements APIKeyService {

    private APIKeyRepo apiKeyRepo;

    @Autowired
    public APIKeyServiceImpl(APIKeyRepo apiKeyRepo) {
        this.apiKeyRepo = apiKeyRepo;
    }


    @Override
    public String save(String apiKeyInput) {

        APIKEY apikey = new APIKEY();
        apikey.setApikey(apiKeyInput);

        APIKEY savedKey = apiKeyRepo.save(apikey);

        return null != savedKey ? savedKey.getApikey() : null;
    }

}

现在短回购代码如下:

public interface APIKeyRepo extends JpaRepository<APIKEY, String> {

}

问题是每当我 运行 Sonarlint 报告然后我遇到以下主要问题:

更改此条件,使其不总是计算为真

发生在三元运算符代码处:

return null != savedKey ? savedKey.getApikey() : null;

我不太明白其中哪一部分将始终评估 true

当您保存实体时,保存方法将return您保存的实体,它永远不会为空。

来源:方法文档