Can IntelliJ auto-generate code to null-check arguments when using @ParametersAreNonnullByDefault annotation on package

孤人 提交于 2019-12-11 15:05:10

问题


I like the feature where IntelliJ can automatically generate code to check at runtime for null on each argument/parameter passed to a method.

This feature is enabled in Preferences > Build, Execution, Deployment > Compiler > Add runtime assertions for notnull-annotated methods and parameters (checkbox). The neighboring Configure annotations button configures which annotation package.

I am trying to set my not-null annotation at the package level. Example:

@ParametersAreNonnullByDefault
package work.basil.ticktock.backend.data;

import javax.annotation.ParametersAreNonnullByDefault;

My question is: Which, if any, of these "Configure annotations" work the generate code for the @ParametersAreNonnullByDefault annotation discussed here and found here?

The null-checks are indeed working within the code editor, generating warnings. But I want runtime-checking as provided by the checkbox shown in this screenshot.


回答1:


Please follow/comment the duplicated feature request already created at YouTrack, but not yet implemented: https://youtrack.jetbrains.com/issue/IDEA-164347. Thank you.



来源:https://stackoverflow.com/questions/57828113/can-intellij-auto-generate-code-to-null-check-arguments-when-using-parametersar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!