在包上使用@ParametersAreNonnullByDefault注释时,IntelliJ可以自动生成代码以对参数进行空检查吗? [英] Can IntelliJ auto-generate code to null-check arguments when using @ParametersAreNonnullByDefault annotation on package
问题描述
我喜欢IntelliJ可以自动生成代码以在运行时检查 传递给方法的每个参数/参数是否为空的功能.
I like the feature where IntelliJ can automatically generate code to check at runtime for null on each argument/parameter passed to a method.
在Preferences
> Build, Execution, Deployment
> Compiler
> Add runtime assertions for notnull-annotated methods and parameters
中启用此功能(复选框).相邻的Configure annotations
按钮配置哪个注释包.
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;
我的问题是:这些配置注释"中的哪个(如果有的话)为@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.
推荐答案
请关注/评论在YouTrack已创建但尚未实现的重复功能请求:
Please follow/comment the duplicated feature request already created at YouTrack, but not yet implemented: https://youtrack.jetbrains.com/issue/IDEA-164347. Thank you.
这篇关于在包上使用@ParametersAreNonnullByDefault注释时,IntelliJ可以自动生成代码以对参数进行空检查吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!