我正在尝试使用来自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 Report时,我就会遇到以下主要问题:
更改此条件,以便它不总是评估为true
这是在三元运算符代码处发生的:
return null != savedKey ? savedKey.getApikey() : null;
我不太了解其中的哪一部分总是正确。
最佳答案